Ru - Помогите мне пожалуйста, всё было хорошо, всё запускалось, я ничего не менял и тут перестало работать. En - Help me please, everything was fine, everything started up, I didn't change anything and then it stopped working.
Вот сайт с которого нужен парсинг - https://www.avito.ru/rossiya?q=%D0%B0%D0%B2%D1%82%D0%BE
Traceback (most recent call last): File "C:\Users\123\Desktop\парс авито+\test.py", line 11, in maxPages = bs.find("div", class_="js-pages pagination-pagination-FSNE").find_all("span", class="pagination-item-JJq_j")[7].get("data-marker").replace("page(", "").replace(")", "") AttributeError: 'NoneType' object has no attribute 'find_all'
from bs4 import BeautifulSoup
import requests
product = input("Введите название предмта: ")
delivery = 0
def start():
print("Фильтры: ")
d = input("Авито Доставка: ")
if d == "да" or d == "Да" or d == "ДА":
delivery = 1
get_total_pages()
elif d == "нет" or d == "Нет" or d == "НЕТ":
get_total_pages()
def get_total_pages():
page = 0
url = "https://www.avito.ru/rossiya?cd=1&d=" + str(delivery) + "&f=ASgCAgECAUXGmgwYeyJmcm9tIjo1MDAwLCJ0byI6MTUwMDB9&p=" + str(page) + "&q=" + product
#url = "https://www.avito.ru/rossiya?q=" + product
request = requests.get(url.strip())
bs = BeautifulSoup(request.text, "html.parser")
maxPages = bs.find("div", class_="js-pages pagination-pagination-_FSNE").find_all("span", class_="pagination-item-JJq_j")[7].get("data-marker").replace("page(", "").replace(")", "")
print("Всего страниц: " + str(maxPages))
get_html(page, maxPages)
def get_html(page, maxPages):
page += 1
print("1" + str(page))
url = "https://www.avito.ru/rossiya?cd=1&d=" + str(delivery) + "&f=ASgCAgECAUXGmgwYeyJmcm9tIjo1MDAwLCJ0byI6MTUwMDB9&p=" + str(page) + "&q=" + product
request = requests.get(url.strip())
bs = BeautifulSoup(request.text, "html.parser")
page_pars(bs, page, maxPages)
def page_pars(bs, page, maxPages):
data = bs.find("div", class_="iva-item-titleStep-_CxvN")
for value in data:
try:
title = data.find("a", class_="title-listRedesign-XHq38").text.strip()
except:
title = ""
try:
price = bs.find("span", class_="price-text-E1Y7h").text.strip().replace("\xa0", "")
except:
price = ""
try:
link = "https://www.avito.ru/" + data.find("a", class_="iva-item-title-_qCwt")["href"]
except:
link = ""
info = {'title': title,
'price': price,
'link': link
}
#print((info["title"], info["price"], info["link"]))
if page < int(maxPages):
print("2" + page)
get_html(page, maxPages)
start()