K
K
Kemper54542021-01-16 18:30:59
Python
Kemper5454, 2021-01-16 18:30:59

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

1 answer(s)
A
aleks-th, 2021-01-16
@aleks-th

Just like with one.
Only two in turn.
-- There are
no other options. There may be, but I honestly don't know about them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question