-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
64 lines (52 loc) · 2.04 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import cloudscraper
from bs4 import BeautifulSoup
scraper = cloudscraper.create_scraper(
browser={
'browser': 'chrome',
'platform': 'windows',
'desktop': True
}
)
def get_user(username: str):
url = f'https://fragment.com/username/{username}'
response = scraper.get(url)
response.encoding = 'utf-8'
if response.status_code == 403:
return "Response code is 403.\nYour request likely was flagged by Cloudflare and it requires captcha, try to slow down or change IP"
soup = BeautifulSoup(response.text, 'html.parser')
status_section = soup.find(class_='tm-section-header-status')
if not status_section: # note that some usernames might be blocked by Telegram, even if status is free
return '✅ free'
status_class = status_section.get('class', [])
status_dict = {
'tm-status-taken': '❌ taken',
'tm-status-avail': '💶 for sale',
'tm-status-unavail': '❌ unavailable'
}
for status in status_dict.keys():
if status in status_class:
return status_dict[status]
def main():
print("1 - print only avaiable | 2 - print all")
select = int(input("Select: "))
if select not in [1, 2]:
return main()
with open('usernames.txt', 'r') as file:
for line in file:
username = line.strip().lower()
if len(username) >= 4:
status = get_user(username)
if select == 1:
if status == '✅ free':
print(f'{username} | {status}')
with open('available.txt', 'a') as u:
u.write(f"{username}\n")
if select == 2:
if status:
print(f'{username} | {status}')
if status == '✅ free':
with open('available.txt', 'a') as u:
u.write(f"{username}\n")
print("Available usernames was saved into available.txt")
if __name__ == '__main__':
main()