提问人:wally west 提问时间:7/8/2023 最后编辑:Robertwally west 更新时间:7/8/2023 访问量:43
当我尝试使用他们的链接解析channel_ids时,我遇到了“数据库被锁定”的问题
I have a problem "database is locked" when i try to parse channel_ids using their links
问:
我尝试解析只有链接的频道的 id。我在电视马拉松中使用 WITH 构造进行会话,我认为这可能是我的问题,但我不知道。
from telethon.sync import TelegramClient
from telethon.tl.functions.channels import GetFullChannelRequest
from telethon.errors import ChannelInvalidError
def get_channel_id_sec(links):
api_id = ''
api_hash = ''
with TelegramClient('session_name', api_id, api_hash) as client:
channel_ids = []
for link in links:
try:
result = client(GetFullChannelRequest(link))
channel_ids.append(result.chats[0].id)
except ChannelInvalidError:
print(f"Invalid channel: {link}")
return channel_ids
答: 暂无答案
评论