feat(recipe): 获取菜谱时删除没用的形容词
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ching 2024-03-08 17:21:21 +08:00
parent f9eeabbfb9
commit b38fc00072

View File

@ -9,6 +9,7 @@ def get_recipe_from_xiachufang(url):
response.raise_for_status() response.raise_for_status()
soup = bs4.BeautifulSoup(response.text, 'html.parser') soup = bs4.BeautifulSoup(response.text, 'html.parser')
name = soup.find('h1', class_='page-title').text.strip() name = soup.find('h1', class_='page-title').text.strip()
name = name.split('')[-1]
ingredients = [] ingredients = []
for ingredient in soup.find('div', class_='ings').find('table').find_all('tr'): for ingredient in soup.find('div', class_='ings').find('table').find_all('tr'):
ingredients.append(' / '.join([td.text.strip() for td in ingredient.find_all('td')])) ingredients.append(' / '.join([td.text.strip() for td in ingredient.find_all('td')]))