AttributeError: 'int' object has no attribute 'find'
Помогите тупому студенту понять ошибку.. Выводит либо:
File "C:\Python\telegbot.py", line 95, in newst
event = i.find('section').find('h2').find('a').get_text()
AttributeError: 'int' object has no attribute 'find'
либо:
File "C:\Python\telegbot.py", line 95, in newst
event = i.find('section').find('h2').find('a').get_text()
AttributeError: 'NoneType' object has no attribute 'find'
@bot.message_handler(commands=['newst'])
def newst(message):
if message.text == '/newst@PPTlo_bot' or '/newst':
url = 'https://xn--n1acamh.xn--p1ai/news/'
page = requests.get(url)
soup = BS(page.text, 'html.parser')
events = soup.findAll('div', class_='real-content hentry')
r = requests.get('https://xn--n1acamh.xn--p1ai/news/')
div = BS(r.text, 'html.parser')
events = div.find('div', class_='real-content hentry')
answer = ''
for i in events:
event = i.find('section').find('h2').find('a').get_text()
try:
desc = i.find('section').find('div', class_='entry-summary').get_text()
except:
desc = 'Нет описания.'
date = i.find('section').find('time', class_='entry-date published updated').get_text()
answer += events + desc + date + '\n\n'
bot.send_message(message.chat.id, answer)