mylamour / blog

Your internal mediocrity is the moment when you lost the faith of being excellent. Just do it.
https://fz.cool
61 stars 14 forks source link

image download from telegram channel #46

Open mylamour opened 5 years ago

mylamour commented 5 years ago

Update: you can find script here

This is a simple image file download from telegram channel

step1 : my.telegram.com去申请api step2: pip install telethon step3: use telethon download image from channel, this is get.py, you can just run python get.py

import uuid
from telethon import TelegramClient, events, sync
from telethon.tl.types import PeerUser, PeerChat, PeerChannel

api_id=fakeid
api_hash='thisi is fake hash'

client = TelegramClient('session_name', api_id, api_hash)
client.start()

titswiki = client.get_entity('titswiki')

c = client.get_entity(PeerChannel(titswiki.id))
for m in client.iter_messages(c):
        print(m.download_media("image/"+str(uuid.uuid1())))

image