How to use Python to get Telegram channel messages and users list

Поделиться
HTML-код
  • Опубликовано: 16 сен 2024

Комментарии • 117

  • @AmirYousefi
    @AmirYousefi  2 года назад +4

    Have a look here on source code
    github.com/amiryousefi/telegram-analysis

  • @thehuseein
    @thehuseein 2 года назад +1

    I'm very happy and proud to see a "ham vatan" has a great youtube channel like this. khoda ghovat ;)

  • @Skilital
    @Skilital Год назад +2

    Thank you so much, I have my project where I need to repost some news from a channel, this saves my life!

  • @yepayamdaram
    @yepayamdaram 2 года назад

    دمت گرم خیلی دنبال اینجور آموزشی میگشتم

  • @FarhadHassanpour
    @FarhadHassanpour 2 года назад +1

    Great, Telegram is the best messenger in the world 💪

    • @AmirYousefi
      @AmirYousefi  2 года назад +1

      And it's very developer friendly!

  • @MegaMzryo
    @MegaMzryo Год назад +1

    Thank you Amir, this helped me out so much!

  • @mehdinamvar2219
    @mehdinamvar2219 2 года назад +1

    Great! Very helpful video!
    The Medium article helped me a lot too.

  • @V4mpirella
    @V4mpirella Год назад

    Wow amazing work. I'm gonna watch this video as many times as I and so I can understand it because this is very interesting and very precisely good with information. You are awesome thank you so much.

  • @somajuice666
    @somajuice666 2 года назад

    You Helped me immensly!!! thank you so much good Sir! I was looking and looking everywhere but could not find this!

    • @kjnetwork732
      @kjnetwork732 2 года назад

      i need your help please comment back

  • @codehiringnetwork
    @codehiringnetwork 10 месяцев назад

    beautiful work! Thanks you

  • @pedrosavio99
    @pedrosavio99 2 года назад +1

    Thank you very much you are amazing!!!!

  • @norrisjay
    @norrisjay 2 года назад +3

    Mr. Amir, thank you for this! I have two questions:
    1. Was wondering if it is possible to extract messages from multiple channels and each have its own json file?
    2. Set this up in a cron job. How to deal with the login?
    Appreciate it, thank you very much :)

    • @AmirYousefi
      @AmirYousefi  2 года назад +4

      1. For that you need to either run multiple instances of this script or make a little adjustment in the code to read a list of channels and go through them on a loop.
      2. After the first time you do the login process, there will be a session file created for your Telegram account so the next time you don't need to do the login. But be careful about where you run this script because with those session files there's a possibility to login to your Telegram account.

    • @fleppeR252
      @fleppeR252 2 года назад

      Did you come up with a working loop for the task in question 1?

  • @amin6e69
    @amin6e69 2 года назад +1

    Its helpful, tnx.

  • @kickbuttowski8201
    @kickbuttowski8201 2 года назад +2

    This was fantabulous
    i have a trouble...need your suggestion
    I'm able to scrape the entire groups msg data with your script
    however i want to scrape only recent 100 msg in a loop and check for some keywords in that message!
    is it possible?

    • @AmirYousefi
      @AmirYousefi  2 года назад +1

      You need to add some code inside the for loop to count the message numbers and maybe a function to check for your keyword in the scrapped message.

  • @ADT3C
    @ADT3C Год назад

    thanks amir
    it's very useful

    • @manishsahu6217
      @manishsahu6217 Год назад

      Hey can we get any channel messages which is private and we are not part of it

  • @MarcioAramuni
    @MarcioAramuni Год назад +1

    Excellent work. But there is a problem: After the phone number comes this error "The api_id/api_hash combination is invalid (caused by SendCodeRequest)". I have checked api_id/api_hash combination and it is rights. Looking around there is a lot of people with the same issue.

  • @majidnazari935
    @majidnazari935 Год назад

    Great!! Thanks

  • @denizhan1010
    @denizhan1010 2 года назад

    thanks for good share.

  • @fleppeR252
    @fleppeR252 2 года назад

    Great video thanks! Will the script you provided retrieve all message information I.e. user-id, forwarded_from etc.?

  • @gabrielferrer2400
    @gabrielferrer2400 Год назад

    Thank you Amir for this amazing tutorial! Is username just username and not the URL of the username?

  • @maximkuchiga141
    @maximkuchiga141 2 года назад

    thanks a lot!

  • @Miracle_Tech5347
    @Miracle_Tech5347 2 года назад +4

    How to get message of private group with out membership but using link

  • @DINESHMANIKONDA
    @DINESHMANIKONDA Год назад

    Thanks a lot

  • @nicovon118
    @nicovon118 2 года назад +1

    A question mr Amir Yousefi, does it take real time messages? or is there some sort of delay? thanks in advance

  • @xuloIsaias
    @xuloIsaias 2 года назад +2

    Hi Amir, I´ve got this error :( RuntimeWarning: coroutine 'UserMethods.is_user_authorized' was never awaited
    if not client.is_user_authorized():
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback Is this familiar to you?

    • @AmirYousefi
      @AmirYousefi  2 года назад

      I'm not facing this issue.
      Could you please check the latest code from GitHub and check your Python version and requirements?

  • @snehaart7763
    @snehaart7763 2 года назад +1

    Bro this now not working

  • @narasimmank1204
    @narasimmank1204 Год назад +1

    bro i gave channel url but i got this error....... if not participants.users:
    AttributeError: 'coroutine' object has no attribute 'users'
    sys:1: RuntimeWarning: coroutine 'UserMethods.__call__' was never awaited
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
    sys:1: RuntimeWarning: coroutine 'UserMethods.get_entity' was never awaited
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback

  • @WuKhong-v4c
    @WuKhong-v4c 9 месяцев назад

    Hello Amir, this is very useful and I am having issues that the code is not scraping the text if the post is attached photos or videos, do you have any suggestions ?

  • @guto2755
    @guto2755 2 года назад +1

    How do I get only the last message, in looping?

  • @artperforma5563
    @artperforma5563 2 года назад +1

    so I have tried to use your software but getting error with telethon.sync inport telegramchannel, can you please help me how to resolve this issue.

    • @AmirYousefi
      @AmirYousefi  2 года назад

      Can you provide your error message?

  • @misaldi2743
    @misaldi2743 Месяц назад

    If I want to scrap the subtopic/topic info chat from the group, could it be use the same script?

  • @nbamek899
    @nbamek899 2 года назад

    Hi, can you add me more part to this with, how to get updates of an already given message, and also how scrape a channel from its inception or creation time which means to get its data from the creation time or a specific time in the past?
    I appreciate this gonna be helpful.

  • @anushkanarsima9048
    @anushkanarsima9048 Месяц назад

    How do I stop my account from getting banned? It gets banned after a few hundred messages

  • @msaberifard780
    @msaberifard780 9 месяцев назад

    Then active source have gived KeyError: 'Telegram' how to fix it error ?

  • @dubstepworldofficial6840
    @dubstepworldofficial6840 2 года назад +2

    🤙👍👍👍

  • @regisfernandes147
    @regisfernandes147 2 года назад

    I had a problem:
    File "ChannelMessages.py", line 42
    async def main(phone):
    ^
    SyntaxError: invalid syntax.
    How can i fix it?

  • @sunlybiloa606
    @sunlybiloa606 2 года назад

    thank you Amir I have a question is it possible to make a bulk message to all the members of my channel. because you see I am organizing a big event and I would like to reach each member in particular

  • @CryptoExpert22
    @CryptoExpert22 2 года назад

    how can i add a filter to only read certain messages plz

  • @sergiososa5577
    @sergiososa5577 Год назад

    Amir thanks a lot for your code! I have a question, in the console when it asks to enter the phone number, what format should I use? For example, for a telephone number from Argentina, the country code is 54. I have the config.ini file well configured.

    • @sergiososa5577
      @sergiososa5577 Год назад

      i solved, sorry. Thanks for your code!!!

  • @jankotze383
    @jankotze383 8 месяцев назад

    So does this code only pull messages from a channel if you are the owner of it?

  • @doniyorkarimov7
    @doniyorkarimov7 2 года назад

    hi there, sometimes the app is takin too long time to scrap, and even doesn`t stop. how to fix it. or how to make it to search messages with specific keyword?

  • @iqbalvoices
    @iqbalvoices Год назад

    empty response is coming why? i.e nothing n json file only [] is there

  • @ajibolaolanipekun7368
    @ajibolaolanipekun7368 2 года назад +1

    Pls, Can you help with a Telegram BOT that can read from telegram group and automate the command on trading broker

    • @AmirYousefi
      @AmirYousefi  2 года назад

      Seems like a project to me 😀
      I'm not currently available to record this much of work but you can send an inquiry to my email explaining your needs in details.

  • @dilip.rajkumar
    @dilip.rajkumar Год назад

    How do I modify this script to read only the latest incoming message continuously in a private telegram channel and deploy the script in a serverless environment (like AWS lambda)?

  • @Foulaniyy
    @Foulaniyy 2 года назад

    Hello,THhank you fore the post, it's very useful, I would like to get audios from a channel wich is a course channel on a weekly bases. If I need every wensdays' class' audio from the oldest to the newest, wich modification should I give to the code. Thank you dear Amir! Allahumma baarik fiik!

  • @mandarpatil2310
    @mandarpatil2310 2 года назад +1

    Sir if I type my phone number then shows error about invalid api key

    • @AmirYousefi
      @AmirYousefi  2 года назад

      Did you set everything correct in the configuration file?

    • @mandarpatil2310
      @mandarpatil2310 2 года назад

      @@AmirYousefi got it sir, how I get the latest message from channels

  • @QingquanChen-h2g
    @QingquanChen-h2g Год назад

    Whenever launching telethon from an existing session I receive two error messages:
    Server sent a very new message with ID xxxxxxxxxxxxxxxxxxx, ignoring Server sent a very new message with ID xxxxxxxxxxxxxxxxxxx, ignoring. Could you help me, thanks

  • @abhisheksuna7168
    @abhisheksuna7168 6 месяцев назад

    Is it possible to extract quiz from telegram ?

  • @gokhanfidan4636
    @gokhanfidan4636 2 года назад +2

    Traceback (most recent call last):
    File "c:\Users\gokha\Desktop\telegram-analysis-master\ChannelMessages.py", line 31, in
    api_id = config['Telegram']['api_id']
    File "C:\Users\gokha\anaconda3\lib\configparser.py", line 963, in __getitem__
    raise KeyError(key)
    KeyError: 'Telegram'
    i've got this error after i copied config.ini and try to run ChannelMessages. could you pls help me ?

    • @maksim0933
      @maksim0933 2 года назад +1

      hah...I have the same problem, it seems that using python scripts requires understanding the whole process

    • @maksim0933
      @maksim0933 2 года назад +1

      by the way...be sure to rename the config file properly!

    • @emansarahafi
      @emansarahafi 2 года назад

      I had the same problem but it worked when I replaced config.ini in the line config.read("config.ini") with the entire path to the file instead.

    • @WikiReever
      @WikiReever 2 года назад

      @@emansarahafi not working me i'm stuck here
      PS C:\Users\Issam\Downloads\telegram-analysis-master> Python ChannelMessages.py
      Traceback (most recent call last):
      File "C:\Users\Issam\Downloads\telegram-analysis-master\ChannelMessages.py", line 31, in
      api_id = config['Telegram']['api_id']
      File "C:\Users\Issam\AppData\Local\Programs\Python\Python310\lib\configparser.py", line 964, in __getitem__
      raise KeyError(key)
      KeyError: 'Telegram'

    • @darshankokal4670
      @darshankokal4670 2 года назад

      you can simply hard code the values in variables and then run the script.
      But still this script is not showing me any msg. IDK why

  • @shenchu2441
    @shenchu2441 Год назад +1

    Hi Amir, thanks for the useful tutorial! Could you explain the purpose of using async and await in this script?

  • @wecare4u652
    @wecare4u652 2 года назад

    Hello sir,
    While I am trying to run channelusers file I am getting chat admin privileges are required error. Can you please tell me how to resolve it?

  • @lenrock12022001
    @lenrock12022001 2 года назад

    @all I'm experiencing a weird bug, when reading messages from a test group I made.. it reads weird messages, and I think that is because I am reading messages from another telegram users account for some reason? I do not know why this is happening because I used my own phone number and the login on my account was successful. any one experienced the same and how did you fix this?
    also, great tutorial ang code

  • @MohkKh
    @MohkKh 2 года назад

    sorry for my english
    This code cant read private or public channel that make copyright on their messages 😢

  • @sobhanmovassagh6792
    @sobhanmovassagh6792 Год назад

    سلام از ایران وقتی می خوام api hash را بگیرم ارور میده راه حل نداره؟

  • @baizhanyshbaizrakhmanov7593
    @baizhanyshbaizrakhmanov7593 Год назад

    Hi, thanks for video! I get struct.error: argument out of range Task was destroyed but it is pending!

  • @devilgaming5543
    @devilgaming5543 2 года назад +1

    How can i use it to get messages of a telegram private channel pls help me

    • @AmirYousefi
      @AmirYousefi  2 года назад

      You can do so If you are a member of that Telegram channel.

    • @smartap
      @smartap 6 месяцев назад

      @@AmirYousefi But how to do it? Search a lot but there is no way.....Please guide me.

  • @musicstudio3191
    @musicstudio3191 Год назад

    I want to get users list with telegraf (Nodejs) , you have any hint for me ?m

  • @beautifullectures
    @beautifullectures 2 месяца назад

    Hi, i have lost my channel ownership can u help?

  • @lespritshonen9633
    @lespritshonen9633 2 года назад +1

    it is possible to see others channels members list?

    • @AmirYousefi
      @AmirYousefi  2 года назад

      Generally Telegram only allow you to see your own channel/groups members list. For other channels/groups you need administrative permissions.

  • @chamindakumara40
    @chamindakumara40 2 года назад +1

    sir, what is this error. Warning (from warnings module):
    File "E:/TelegramBot/amirbot.py", line 25
    if not client.is_user_authorized():
    RuntimeWarning: coroutine 'UserMethods.is_user_authorized' was never awaited

  • @ashn551
    @ashn551 2 года назад

    Dear, it seems that only members from one's own channel can be scrapped as it's is asking for admin privileges when tried on others channel

    • @AmirYousefi
      @AmirYousefi  2 года назад

      Logically yes, as you can not see other channels members in Telegram. But for groups, If you are a member of it and group admin don't restrict members list from being seen you can grab groups list.

  • @kooroshsanaei
    @kooroshsanaei 8 месяцев назад

    Code Error Mide

  • @user-nk9kj2ed5d
    @user-nk9kj2ed5d Год назад

    Hi, I can read the data but none of the comments they make

  • @vpvcinn3394
    @vpvcinn3394 2 года назад

    How to save the information in Telegram notification?

  • @simonegarro2928
    @simonegarro2928 Год назад

    Is there a way to retrieve messages from a private chat with another person?

  • @pragyanyadav5539
    @pragyanyadav5539 Год назад

    doesn't work for private channels

    • @manishsahu6217
      @manishsahu6217 Год назад

      Bhai private channel ma kam nai krta kya

  • @davisg1072
    @davisg1072 2 года назад

    Does this work even if the channel I am in does not have a link?

  • @DINESHMANIKONDA
    @DINESHMANIKONDA Год назад

    How to read media files from the messages ?

  • @MohkKh
    @MohkKh 2 года назад

    keep getting this error OperationalError: database is locked

  • @rasoulkurd
    @rasoulkurd 7 месяцев назад

    امیر جان این کد هنوز کار می کنه؟

  • @DEV_TARIK
    @DEV_TARIK 2 года назад

    Which brand are you use monitor?

    • @AmirYousefi
      @AmirYousefi  2 года назад

      It's a Xiaomi one( Mi surface 34")

  • @juanboterorave8061
    @juanboterorave8061 2 года назад

    this works for private channels? or just for public?

    • @kickbuttowski8201
      @kickbuttowski8201 2 года назад

      both since you are using your telegram credentials

  • @ryukshinigami3178
    @ryukshinigami3178 2 года назад

    dadash zaban farsi ro chetori mishe encode decode kard , toye data base hexegan miare

  • @aviattri
    @aviattri 2 года назад

    thanks for the source code I have tried to get users from my channel but i am able to get only 200 users how can I get more than 200 users. I have more than 1200 users in my channel

    • @AmirYousefi
      @AmirYousefi  2 года назад

      I've got this answer from StackOverflow, but I need to test it in my source code.
      stackoverflow.com/a/47899940/2536118

  • @hussainirano8043
    @hussainirano8043 2 года назад +1

    Lol sorry I watch but don't really understand what the bot does

    • @AmirYousefi
      @AmirYousefi  2 года назад

      Maybe because it's not a bot 😀

  • @habeshatech766
    @habeshatech766 Год назад

    my telegram account got banneed after this

  • @thechoosen4240
    @thechoosen4240 Год назад

    Good job bro, JESUS IS COMING BACK VERY SOON; WATCH AND PREPARE

  • @VikasKumarSharma1988
    @VikasKumarSharma1988 Год назад

    error
    telethon.errors.rpcerrorlist.ChatAdminRequiredError: Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group (caused by GetParticipantsRequest)

  • @nguyentunglam806
    @nguyentunglam806 Год назад

    i got this problem telethon.errors.rpcbaseerrors.AuthKeyError: RPCError 406: UPDATE_APP_TO_LOGIN (caused by SignInRequest)