Python
- 6 ответов
- 0 вопросов
2
Вклад в тег
import telebot
import config
import time
from bs4 import BeautifulSoup
import requests
bot = telebot.TeleBot(config.TOKEN)
@bot.message_handler(commands=['start'])
def send_welcome(message):
BTCon = True
ETHon = True
r_btc = requests.get('https://bcs-express.ru/kotirovki-i-grafiki/btcusd')
soup_btc = BeautifulSoup(r_btc.content, "lxml")
if BTCon:
btcST = soup_btc.find(class_="quote-head__price-value js-quote-head-price js-price-close").text
btc_msg = bot.send_message(message.chat.id, f'*BTC* {btcST}', parse_mode= 'Markdown')
nur_btc = 0
r_eth = requests.get('https://bcs-express.ru/kotirovki-i-grafiki/ethusd')
soup_eth = BeautifulSoup(r_eth.content, "lxml")
if ETHon:
ethST = soup_eth.find(class_="quote-head__price-value js-quote-head-price js-price-close").text
eth_msg = bot.send_message(message.chat.id, f'*ETH* {ethST}', parse_mode= 'Markdown')
nur_eth = 0
while True:
if BTCon:
nur_btc +=1
btc = soup_btc.find(class_="quote-head__price-value js-quote-head-price js-price-close").text
bot.edit_message_text(chat_id = message.chat.id, message_id = btc_msg.message_id, text = f'*BTC* {btc} - {nur_btc}', parse_mode= 'Markdown')
if ETHon:
nur_eth +=1
eth = soup_eth.find(class_="quote-head__price-value js-quote-head-price js-price-close").text
bot.edit_message_text(chat_id = message.chat.id, message_id = eth_msg.message_id, text = f'*ETH* {eth} - {nur_eth}', parse_mode= 'Markdown')
time.sleep(1)
bot.polling()