오늘은....많은 일이 있었지만 코드에 집중하자.
사실 오늘은 와이어 프레임 및 전체적 프로젝트 진행 상황에 대해 논의 했다. 결과적으로 나는
img를 가져오는(일단 보류지만, 먼저 데이터 수집만 하는 단계)
import requests
import bs4
import pandas as pd # type: ignore
url = 'https://m.10000recipe.com/recipe/list.html'
final_data = []
for i in range(1, 6):
new_url = f'{url}?page={i}'
res = requests.get(new_url)
soup = bs4.BeautifulSoup(res.text, 'html.parser')
items = soup.find_all("div", "media")
for item in items:
title = item.find("span", "jq_elips2").text.strip()
author = item.find("div", "info_name").text.strip()
try:
image = item.find("img", "media-object")["src"]
except Exception as e:
image = ""
print(e)
final_data.append({
"title": title,
"author": author,
"image": image
})
df = pd.DataFrame(final_data)
df.to_csv("result.csv")
이렇게 먼저 img만 가져오는 방식
그리고
time = ['', '', '']
recommendation_history = []
while True:
if time == '아침':
morning_time
if time == 'w':
morning_time
if time == '아침':
morning_time
이렇게 아침, 점심, 저녁으로 나뉠 것 같다.