有一个电报组,其中包含超过40,000个共享文件 是否有任何机器人可以同时下载所有这些机器人?如果没有,是否有使用python下载共享媒体文件的电报api脚本方法?
答案 0 :(得分:1)
遗憾的是,电报僵尸网络api不允许查看旧邮件(或文件)。
执行此操作的唯一方法是使用Telethon等API,就电报而言,它充当用户。
答案 1 :(得分:0)
您可以使用telethon(电报客户端)下载公共组中的所有文件
from telethon import TelegramClient
from tqdm import tqdm
# These example values won't work. You must get your own api_id and
# api_hash from `my.telegram.org` , under API Development.
api_id = APIID
api_hash = 'APIHASH'
client = TelegramClient('session_name', api_id, api_hash)
client.start()
print(client.get_me().stringify())
# client.send_message('username', 'Hello! Talking to you from Telethon')
# client.send_file('username', '/home/myself/Pictures/holidays.jpg')
# client.download_profile_photo('hamidzr')
messages = client.get_messages('intothestates', limit=2000)
print(len(messages))
for msg in tqdm(messages):
client.download_media(msg)
答案 2 :(得分:0)
自胜利者回答以来,Telethon似乎已经改变。 (Docs)
这应该有效:
from telethon.sync import TelegramClient, events
from tqdm import tqdm
import os
# These example values won't work. You must get your own api_id and
# api_hash from https://my.telegram.org, under API Development.
api_id = <api_id>
api_hash = '<api_hash>'
with TelegramClient('name', api_id, api_hash) as client:
messages = client.get_messages('<channel/chat>', limit=50) # limit defaults to 1
for msg in tqdm(messages):
msg.download_media(file=os.path.join('media', '<file_name>'))