92 lines
1.9 KiB
Python
92 lines
1.9 KiB
Python
import requests
|
||
from bs4 import BeautifulSoup as bs
|
||
import re
|
||
import function as f
|
||
|
||
link = 'https://povar.ru/list/'
|
||
|
||
|
||
|
||
def pars_group(link):
|
||
#Сбор видов блюд
|
||
response = f.try_request(link)
|
||
soup = bs(response.text, 'html.parser')
|
||
|
||
main_container = soup.find_all(class_='ingredientItem')
|
||
|
||
|
||
for items in main_container:
|
||
|
||
item = items.find_all('a')
|
||
title = item[0].get_text()
|
||
|
||
if title == 'Салаты': break
|
||
|
||
print(title)
|
||
|
||
for i in item[1::]:
|
||
name_group = i.get_text()
|
||
link_group = 'https://povar.ru' + i.get('href')
|
||
print('-'*5, name_group, link_group)
|
||
|
||
print('-'*50)
|
||
|
||
|
||
def pars_dishs(link='https://povar.ru/list/spagetti/', page=0):
|
||
#Сбор списка рецептов
|
||
while True:
|
||
page += 1
|
||
new_link = link + str(page)
|
||
soup = f.try_soup(f.try_request(new_link))
|
||
|
||
if soup == False: break
|
||
|
||
main_container = soup.find_all(class_='listRecipieTitle')
|
||
|
||
for items in main_container:
|
||
recipe_name = items.get_text()
|
||
recipe_link = 'https://povar.ru' + items.get('href')
|
||
|
||
print(recipe_name, recipe_link)
|
||
print('-'*50)
|
||
|
||
|
||
|
||
def pars_recipie(link='https://povar.ru/recipes/slivochnaya_karbonara-73186.html'):
|
||
|
||
response = f.try_request(link)
|
||
soup = bs(response.text, 'html.parser')
|
||
|
||
main_container = soup.find(class_='cont_area hrecipe')
|
||
|
||
#detailed_tags = main_container.find(class_='detailed_tags') #Собираем теги
|
||
#detailed_tags = f.extract_tags_from_detailed_tags(detailed_tags)
|
||
|
||
#ingredients = f.extr_ingredient(main_container) #Собираем ингредиенты
|
||
#print(ingredients)
|
||
|
||
#calories_info = f.extract_nutrition(main_container.find_all(class_='circle')) #БЖУ
|
||
#print(calories_info)
|
||
|
||
steps = f.extr_steps(main_container)
|
||
print(steps)
|
||
|
||
|
||
|
||
#pars_group(link)
|
||
#pars_dish()
|
||
pars_recipie()
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|