【问题标题】:Failed to connect to telegram via telethon无法通过 Telethon 连接到电报
【发布时间】:2019-06-15 02:08:45
【问题描述】:

我正在尝试通过 Python 应用程序中的 Telethon 连接到电报

proxy_ip = str('188.166.86.173')
proxy_port = str(1080)
with TelegramClient('anon',
                api_id='123456',
                api_hash='1234567890abcdf',
                proxy=(socks.SOCKS5, str(proxy_ip), proxy_port,True),
                connection=connection.tcpmtproxy.TcpMTProxy
                ) as client:

我明白了

getaddrinfo() 参数 1 必须是字符串或无

我不明白我在哪里使用了错误的参数

【问题讨论】:

  • 好吧,proxy_port 应该是一个 int 并且你正在对一个字符串执行 str()。另外,删除你不需要的 connection= 部分。最后,您的代理似乎无法正常工作。

标签: python telegram telethon


【解决方案1】:

首先 ping 您的代理以检查它是否正常工作, 然后改变这个:

proxy_port = str(1080)

到这里:

proxy_port = 1080

您应该将 proxy_port 作为 int 而不是字符串传递。 你不需要这个connection=connection.tcpmtproxy.TcpMTProxy) as client: 所以从你的代码中删除它。 现在应该没问题。 查看文档以获取有关您问题的更多信息: Creating a Client in telethonn

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-05
    • 1970-01-01
    • 1970-01-01
    • 2017-04-25
    • 2020-05-12
    • 2018-08-13
    • 2011-06-17
    相关资源
    最近更新 更多