Написал простенький парсер, выдает None.
Обязательно ли использовать selenium?
import requests
from bs4 import BeautifulSoup
URL = 'http://www.zagrya.ru/'
HEADERS = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9/',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
}
def get_html(url, params = ''):
r = requests.get(url,headers =HEADERS, params=params)
return r
def get_content(html):
soup = BeautifulSoup(html, 'html.parser')
items = soup.find_all('span', class_='hor-menu__item has-subm')
tovari = []
for item in items:
tovari.append(
{
'karegoria': item.find('a', {'class':'hor-menu__lnk'}).find('span', {'class':'hor-menu__text'}).get_text(),
}
)
return tovati
html = get_html(URL)
print(get_content(html.text))
Заранее спасибо за ответ:)