英文:
How to fetch data from telegram having channel name/title using Telethon?
问题
如何使用Telethon从Telegram的公共频道获取数据。我有频道名称,但没有频道ID或频道用户名。
例如,对于Telegram频道Kadyrov_95,ID是1141171940,标题是Kadyrov_95,用户名是RKadyrov_95。
我知道如果我有频道ID或频道用户名,我可以获取频道的其余详情。但是,如果我只有频道名称/标题,如Kadyrov_95,我该如何做同样的事情?
请帮助。提前感谢!
英文:
How can I fetch data from telegram's public channel using Telethon. I have channel name and I don't have channel ID or channel username.
Example: for the telegram channel, Kadyrov_95, ID is 1141171940, title is Kadyrov_95 and username is RKadyrov_95
I know if I have channel ID or channel username, I can fetch rest of channel details. But, how can I do the same if I only have channel name/title i.e Kadyrov_95
Kindly assist. Thanks in advance!
答案1
得分: 1
只有像 Telegram 客户端一样,剩下的唯一选项就是全局搜索,以防您不是所述聊天的成员。
请查看 SearchRequest
以及页面下面的代码块。
如果您只需要频道,请访问 响应 中的 .chats(如果找到了聊天)。
if r := result.chats:
print(r[0].username)
英文:
As any Telegram clients, the only option left is to search it globally, in case you aren't a member of said chat.
see SearchRequest
and the code block underneath the page.
and if you only need channels, access the .chats in the response (if a chat was found).
if r := result.chats:
print(r[0].username)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论