├── README.md
└── erfan4lx.py
/README.md:
--------------------------------------------------------------------------------
1 | # Telegram-Channel-Member-Scraper
2 | Scraping The Accounts Of Telegram Channel Members To add those to Group or Channel
3 | ***
4 | Get To Know The Best Tool To Scrape Telegram Channel Members
5 | ***
6 |
7 | MY OFFICIAL WEBSITE : https://erfan4lx.com
8 |
9 | Show full video on YouTube : Video was deleted by YouTube, you can get the video by send me a message
10 |
11 | Contact with me to get the Password of Zip file on :
12 |
13 | Telegram : https://t.me/erfan4lx10
14 |
15 | Email : erfan4lx@gmail.com
16 |
17 | 🆔My YouTube Channel : https://youtube.com/erfan4lx
18 |
19 | 🆔My Telegram Channel : https://t.me/erfan4lx_news
20 |
21 |
22 | Follow Me On
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/erfan4lx.py:
--------------------------------------------------------------------------------
1 | from telethon import TelegramClient
2 | from telethon.tl.functions.messages import GetDialogsRequest
3 | from telethon.tl.types import InputPeerEmpty, InputPeerChannel, InputPeerUser
4 | from telethon.errors.rpcerrorlist import (PeerFloodError, UserNotMutualContactError ,
5 | UserPrivacyRestrictedError, UserChannelsTooMuchError,
6 | UserBotError, InputUserDeactivatedError)
7 | from telethon.tl.functions.channels import InviteToChannelRequest
8 | import time, os, sys, json
9 |
10 | wt = (
11 | """
12 | [[ye]]* ) (
13 | [[re]]` ) /( ) ( ) )\ )
14 | [[ye]]( )(_))( /( ( )\ ( ( ((_)( /(
15 | [[re]](_(_()) )(_)) )\ )((_) )\ ' )\ _ )(_))
16 | [[gr]]|_ _|((_)_ _(_/( (_) _((_)) ((_)| |((_)_
17 | [[gr]]| | / _` || ' \))| || ' \()/ _ \| |/ _` |
18 | |_| \__,_||_||_| |_||_|_|_| \___/|_|\__,_|
19 | [[re]][erfan4lx][[ye]]
20 | [[re]][https://erfan4lx.com][[ye]]
21 | [[re]][youtube.com/erfan4lx][[ye]]
22 |
23 | github.com/erfan4lx
24 | instagram.com/_erfan4lx_
25 | t.me/erfan4lx10
26 | """
27 | )
28 |
29 | print(wt)
30 | time.sleep(3)
31 |
32 | COLORS = {
33 | "re": "\u001b[31;1m",
34 | "gr": "\u001b[32m",
35 | "ye": "\u001b[33;1m",
36 | }
37 | re = "\u001b[31;1m"
38 | gr = "\u001b[32m"
39 | ye = "\u001b[33;1m"
40 | def colorText(text):
41 | for color in COLORS:
42 | text = text.replace("[[" + color + "]]", COLORS[color])
43 | return text
44 | clearType = input('terminal or cmd. (t/c): ').lower()
45 | if clearType == 't':
46 | clear = lambda:os.system('clear')
47 | elif clearType == 'c':
48 | clear = lambda:os.system('cls')
49 | else:
50 | print('Invalid input!!!')
51 | sys.exit()
52 |
53 | if sys.version_info[0] < 3:
54 | telet = lambda :os.system('pip install -U telethon')
55 | elif sys.version_info[0] >= 3:
56 | telet = lambda :os.system('pip3 install -U telethon')
57 |
58 | telet()
59 | time.sleep(1)
60 | clear()
61 |
62 | if os.path.isfile('erfan4lx_log.txt'):
63 | with open('erfan4lx_log.txt', 'r') as r:
64 | data = r.readlines()
65 | api_id = data[0]
66 | api_hash = data[1]
67 |
68 | else:
69 | api_id = input('Enter api_id: ')
70 | api_hash = input('Enter api_hash: ')
71 | with open('erfan4lx_log.txt', 'w') as a:
72 | a.write(api_id + '\n' + api_hash)
73 |
74 | client = TelegramClient('erfan4lx', api_id, api_hash)
75 |
76 | async def main():
77 | chats = []
78 | channel = []
79 | result = await client(GetDialogsRequest(
80 | offset_date=None,
81 | offset_id=0,
82 | offset_peer=InputPeerEmpty(),
83 | limit=2000,
84 | hash=0
85 | ))
86 | chats.extend(result.chats)
87 | for a in chats:
88 | try:
89 | if True:
90 | channel.append(a)
91 | except:
92 | continue
93 | a = 0
94 | print(ye+'Choose a channel to scrape: ')
95 | for i in channel:
96 | print(gr+'['+str(a)+']', i.title)
97 | a += 1
98 | op = input(ye+'Enter a number: ')
99 | if op == '':
100 | print(ye+'Ok. skipping...')
101 | time.sleep(1)
102 | sys.exit()
103 | else:
104 | pass
105 | opt = int(op)
106 | print('')
107 | print(ye+'[+] Fetching Members...')
108 | time.sleep(1)
109 | target_group = channel[opt]
110 | all_participants = []
111 | mem_details = []
112 | all_participants = await client.get_participants(target_group)
113 | for user in all_participants:
114 | try:
115 | if user.username:
116 | username = user.username
117 | else:
118 | username = ""
119 | if user.first_name:
120 | firstname = user.first_name
121 | else:
122 | firstname = ""
123 | if user.last_name:
124 | lastname = user.last_name
125 | else:
126 | lastname = ""
127 |
128 | new_mem = {
129 | 'uid': user.id,
130 | 'username': username,
131 | 'firstname': firstname,
132 | 'lastname': lastname,
133 | 'access_hash': user.access_hash
134 | }
135 | mem_details.append(new_mem)
136 | except ValueError:
137 | continue
138 |
139 | with open('erfan4lx_members.txt', 'w') as w:
140 | json.dump(mem_details, w)
141 | time.sleep(1)
142 | print(ye+'Please wait.....')
143 | time.sleep(3)
144 | done = input(gr+'[+] Members scraped successfully.')
145 | await client.disconnect()
146 | print(wt)
147 | time.sleep(3)
148 | sys.exit()
149 |
150 | with client:
151 | client.loop.run_until_complete(main())
152 |
--------------------------------------------------------------------------------