微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

协助修复 Telethon 抓取代码,总是返回错误

如何解决协助修复 Telethon 抓取代码,总是返回错误

使用 python pip install telethon 安装 Telethon scraper 后 并运行下面的代码

from telethon.sync import TelegramClient
api_id = 7072283
api_hash = 'Oadf8d756f690ca4e02d0yuy8c80c3042'
phone = '+23491675214'
client = TelegramClient(phone,api_id,api_hash)

client.connect()
if not client.is_user_authorized():
   client.send_code_request(phone)
   client.sign_in(phone,input('Enter the code: '))


from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty
chats = []
last_date = None
chunk_size = 200
groups=[]

result = client(GetDialogsRequest(
            offset_date=last_date,offset_id=0,offset_peer=InputPeerEmpty(),limit=chunk_size,hash = 0
        ))
chats.extend(result.chats)

我总是收到这个错误

Traceback (most recent call last):
  File "<stdin>",line 1,in <module>
  File "/home/vicky/.local/lib/python3.8/site-packages/telethon/sync.py",line 39,in syncified
    return loop.run_until_complete(coro)
  File "/usr/lib/python3.8/asyncio/base_events.py",line 616,in run_until_complete
    return future.result()
  File "/home/vicky/.local/lib/python3.8/site-packages/telethon/client/users.py",line 30,in __call__
    return await self._call(self._sender,request,ordered=ordered)
  File "/home/vicky/.local/lib/python3.8/site-packages/telethon/client/users.py",line 79,in _call
    result = await future
telethon.errors.rpcerrorlist.AuthKeyUnregisteredError: The key is not registered in the system (caused by GetDialogsRequest)

请帮帮我 注意我使用的是运行 ubunto 20.4 的 linux 系统

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。