It was written in an easy-to-understand manner about the importance of data analysis and machine learning. In addition, it describes how and how much effort Gunosy's targeting and user optimization is done.
I was away from programming for about a month on my internship, but I decided to study with the goal of creating a gourmet curation site.
Short-term goal: Create a simple curation site Ultimate goal: A curation site that goes beyond Gurunavi. Recommand function so that you can choose a store without spending time
Goal of this article: Scraping tabelog and outputting store name and URL by SCV
I will spell it as a memo and diary
first.py
import csv
import requests
from bs4 import BeautifulSoup
import re
urlName = "https://tabelog.com/osaka/A2701/A270103/rstLst/?SrtT=rt&Srt=D&sort_mode=1"
dataHTML = requests.get(urlName)
soup = BeautifulSoup(dataHTML.content, "html.parser")
elems = soup.select('a.list-rst__rst-name-target.cpy-rst-name')
#data = elems.text
with open(r'C:\Users\daisuke\Desktop\python\first.csv', 'w') as f:
for i in elems:
url = re.search(r'"http.*/"', str(i))
url = re.sub(r'"', '', str(url.group()))
name = re.search(r'target="_blank">.*</a>', str(i))
name = re.sub(r'target="_blank">', '', str(name.group()))
name = re.sub(r'</a>', '', name)
print(url)
print(name)
writer = csv.writer(f)
writer.writerow([name,url])
Recommended Posts