I've created a telegram bot using telebot or pyTelegramBotAPI and created a command in it that let's users execute a python script from my server the script actually scrapes information from lots of websites and then display it back to user usingrequests library. This is my approach to do it
import telebot
import requests
from functions.scrape import scrape
API_KEY = 'MY_KEY'
bot = telebot.TeleBot(API_KEY)
@bot.message_handler(commands=['start', 'help'])
def help(message):
bot.send_message(message.chat.id, """
ℹ️ **Command Menu** ℹ️
/help - Displays the command menu
/run - scrape information
""")
@bot.message_handler(commands=['run'])
def run(pm):
values = scrape()
bot.send_message(pm.chat.id, f"scraped values: {values}")
bot.polling()
The script works fine and does execute the scrape function however some requests from
my script automatically fails (out of 300 only 170 requests succeed)
Note - I know the problem lies with telebot itself and not my script cause when i run the same script on my server directly it works flawless without any failed requests i wanted to know what possible reasons might be causing it and how can i fix it or if there any other alternative solutions.