简体   繁体   English

如何使用 python 机器人将本地 html 文件发送到 Telegram

[英]How can I send local html file to Telegram with python bot

this is my code这是我的代码

file_address = './charts/candle_chart.html'
response = bot.sendDocument(chat_id=chat_id, document=file_address, timeout=timeout)

but i got Exception with host not found error但我得到了 Exception with host not found错误

telegram think this file in the web电报认为这个文件在 web

can anybody help me!有谁能够帮我!

Documentation of telegram-bot says:电报机器人的文档说:

 The document argument can be either a file_id, an URL or a file from disk: open(filename, 'rb')

So it must be something like this:所以它必须是这样的:

html_file = open('./charts/candle_chart.html', 'rb')
response = bot.sendDocument(chat_id=chat_id, document=html_file, timeout=timeout)

For more information, see documentation :有关更多信息,请参阅文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM