协助修复 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 (将#修改为@)