如何使用Telethon从Telegram获取具有频道名称/标题的数据?

huangapple go评论74阅读模式
英文:

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)

huangapple
  • 本文由 发表于 2023年3月7日 04:39:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75655605.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定