Запускаю программу, дохожу до момента с вводом номера , ввожу и появляется ошибка:
Traceback (most recent call last):
File "C:\Users\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "C:/Users/PycharmProjects/pythonProject5/main2.py", line 94, in geom
parse()
File "C:/Users/PycharmProjects/pythonProject5/main2.py", line 92, in parse
get_content(html.text)
File "C:/Users/PycharmProjects/pythonProject5/main2.py", line 86, in get_content
imgg = div.find('img')['src']
AttributeError: 'NoneType' object has no attribute 'find'
"
cod:
def geom(message):
print(message.text)
print(type(message.text))
intmes = int(message.text)
listnum = range(1, 851)
if intmes in listnum:
per = str(message)
URL = 'https://megaresheba.ru/gdz/geometriya/8-klass/merzlyak/' + per + '-nomer'
print(URL)
HEADERS = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36',
'accept': '*/*'}
def get_html(url, params=None):
r = requests.get(url, headers=HEADERS, params=params)
return r
imgg = ''
def get_content(html):
global imgg
soup = BeautifulSoup(html, 'html.parser')
div = soup.find('div', {'class': 'with-overtask'})
imgg = div.find('img')['src']
return imgg
def parse():
html = get_html(URL)
if html.status_code == 200:
get_content(html.text)
return html
parse()
print(imgg)