Answer the question
In order to leave comments, you need to log in
How to parse simultaneously from two sites in python?
I'm using BeautifulSoup. How can I scrape from two sites? Throw in one function? I'm just a beginner)
A piece of code is attached:
@bot.message_handler(commands = 'start')
def start(message):
bot.send_message(message.chat.id, 'Привет, введи команду /weather, чтобы узнать погоду в городе')
@bot.message_handler(commands = 'weather')
def weather(message):
headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0' }
resp = requests.get('https://www.gismeteo.ru/weather-tolyatti-4429/', headers=headers).text
soup = BeautifulSoup(resp, 'html.parser')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question