Бот отслеживает курс доллара. Присылает каждые 5 мин сообщения. Когда 1 партия сообщений пришла вылезает ошибка:
(__init__.py:515 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: file must be non-empty" kod:
while True:
if rate == False:
break
#parsing old
#dollar
full_page1 = requests.get(url, headers = headers)
soup1 = BeautifulSoup(full_page1.content, 'html.parser')
convert1 = soup1.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
currency1 = convert1[0].text.replace(',','.')
cur1 = float(currency1)
#old bit
page_f = requests.get(url2, headers = headers)
pars = BeautifulSoup(page_f.content, 'html.parser')
parsingbit = pars.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
bitcoin = parsingbit[0].text.replace(',','.')
bit = bitcoin
bitd = ''.join(bit.split())
time.sleep(300)
if rate == False:
break
#parsing new
#dollar
full_page = requests.get(url, headers = headers)
soup = BeautifulSoup(full_page.content, 'html.parser')
convert = soup.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
currency = convert[0].text.replace(',','.')
cur = float(currency)
#send message
#dollar
if cur > cur1:
bot.send_sticker(message.chat.id, idol1lar)
bot.send_message(message.chat.id, ' Course $ increased: ' + str(cur)+ ' ₽')
elif cur < cur1:
bot.send_sticker(message.chat.id, ldol1lar)
bot.send_message(message.chat.id, ' Course $ lowered: ' + str(cur)+ ' ₽' )
elif cur == cur1:
bot.send_sticker(message.chat.id, hasdol1lar)
bot.send_message(message.chat.id, '⚖️ Course $ has not changed: ' + str(cur) + ' ₽')
else:
bot.send_message(message.chat.id, 'Error')
#new bit
page_f1 = requests.get(url2, headers = headers)
pars1 = BeautifulSoup(page_f1.content, 'html.parser')
parsingbit1 = pars1.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
bitcoin1 = parsingbit1[0].text.replace(',','.')
bit1 = bitcoin1
bit1d = ''.join(bit1.split())
#difference
difference = (float(bitd) - float(bit1d))
difference1 = (float(bit1d) - float(bitd))
if bit > bit1:
bot.send_sticker(message.chat.id, l)
bot.send_message(message.chat.id, ' Course ₿ lowered: ' + str(bit1) + ' ₽\n' + 'Difference: ' + '-' + str(round(difference, 3)) + ' ')
elif bit < bit1:
bot.send_sticker(message.chat.id, it113)
bot.send_message(message.chat.id, ' Course ₿ increased: ' + str(bit1) + ' ₽\n' + 'Difference: ' + '+' + str(round(difference1, 3)) + ' ')
elif bit == bit1:
bot.send_sticker(message.chat.id, hasdol1lar)
bot.send_message(message.chat.id, '⚠️ Course ₿ has not changed: ' + str(bit1) + ' ₽')
else:
bot.send_message(message.chat.id, 'Error')
Как исправить?