Answer the question
In order to leave comments, you need to log in
How to implement stop messages?
There is a piece of code
def parser(message):
bot.send_message(message.chat.id, 'Проверка доступности сайта')
URL = message.text
html = get_html(URL)
cars = []
if html.status_code == 200:
pages_count = get_pages(html.text)
bot.send_message(message.chat.id, 'Сайт доступен, перехожу к парсингу')
for page in range(1, pages_count+1):
html = get_html(URL, params={'page': page})
cars.extend(get_content(html.text))
for car in cars:
bot.send_message(message.chat.id, f'Название: {car["title"]}\nЦена: {car["price"]}\nСсылка: {car["link"]}')
time.sleep(1)
else:
print('Error: '+ html.status_code)
bot.send_message(message.chat.id, 'Ошибка: '+html.status_code+'\nПереслать @dtpl2')
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