Не могу понять в чём ошибка, буду признателен за помощь!
Вот сама ошибка:
Traceback (most recent call last):
File "C:\Users\users\Desktop\����� ����� (3)\parser.py", line 24, in
main()
File "C:\Users\users\Desktop\����� ����� (3)\parser.py", line 18, in main
total_pages = get_total_pages(get_html(url))
File "C:\Users\users\Desktop\����� ����� (3)\parser.py", line 8, in get_total_pages
soup = BeautifulSoup(html, 'html.parser')
File "C:\Users\users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\bs4\__init__.py", line 245, in __init__
elif len(markup) <= 256 and (
TypeError: object of type 'NoneType' has no len()
и вот код программы:
import requests
from bs4 import BeautifulSoup
def get_html(url):
r = requests.get(url)
def get_total_pages(html):
soup = BeautifulSoup(html, 'html.parser')
pages = soup.find('div', class_="pagination-pages clearfix").find_all('a', class_="pagination-page")[-1].get('href')
total_pages = pages.split('=')[1].split('&')[0]
return int(total_pages)
def main():
url = 'https://www.avito.ru/moskva/noutbuki?p=1&q=lenovo'
BASE_URL = 'https://www.avito.ru/moskva/noutbuki?'
PAGE_PART = 'p='
QUERY_PART ='&q=lenovo'
total_pages = get_total_pages(get_html(url))
for i in range(1, total_pages):
url_gen = BASE_URL + PAGE_PART + str(i) + QUERY_PART
print(url_gen)
if __name__ == '__main__':
main()