首页 > 解决方案 > 我如何将数据发送到电报?

问题描述

我尝试将一些数据帧结果发送到电报机器人。你可以帮帮我吗?

import requests
from bs4 import BeautifulSoup as bs
import pandas as pd
from datetime import date
import telegram

tmp = pd.read_excel('sto_list.xlsx')
tmp = tmp[~tmp['Site address'].isna()]
tmp = tmp.reset_index(drop=True)

outcome = []
for add in tmp['Site address']:
    html_get = requests.get(add)
    html = bs(html_get.text, 'html.parser')
    try:
        opening = html.find_all(attrs={'name': 'opening-hours'})[0].text
        if opening[-6:] == 'Closed':
            outcome.append('Closed')
        else:
            outcome.append('Open')
    except IndexError:
        outcome.append('Invalid address')

fout = pd.concat([tmp, pd.DataFrame(outcome, columns=['Open'])], axis=1)

print(fout)

bot = telegram.Bot(token='token')
bot.sendMessage(chat_id=000000, text)

标签: pythontelegram

解决方案


推荐阅读