Парсинг баланса в телегу
Нужно, чтобы бот брал инфу с личного кабинета и выводил баланс, но вместо этого он пишет так:
Ваш баланс: []
import requests
import telebot
from bs4 import BeautifulSoup as BS
bot = telebot.TeleBot("ТОКЕН")
url = 'https://stat.system-ural.ru/'
login = 'se0017'
password = '...'
session = requests.Session()
r = requests.get(url)
html = BS(r.content, 'html.parser')
for el in html.select('table'):
summa = el.select('.td.utm-cell')
@bot.message_handler(commands=["start"])
def main(message):
bot.send_message(message.chat.id, f"Ваш баланс: {summa}")
bot.polling(none_stop=True)
Ответы (1 шт):
Автор решения: Muxe1
→ Ссылка
Держи
import telebot
import requests
from bs4 import BeautifulSoup as BS
bot = telebot.TeleBot("ТОКЕН")
authdata = {'login': 'se0017', 'password': '...'}
session = requests.Session()
response = session.post('https://stat.system-ural.ru/', data=authdata)
parsedata = session.post('https://stat.system-ural.ru')
html = BS(parsedata.content, 'html.parser')
items = html.find_all("td", class_="utm-cell")
kot = []
for item in items:
a = item.text
kot.append(a)
summ = kot[7]
@bot.message_handler(commands=["start"])
def main(message):
bot.send_message(message.chat.id, f"Ваш баланс: {summ}")
bot.polling(none_stop=True)
Верстальщик этого сайта скорее всего был на грибах XD