Muttered3 commited on
Commit
7eeead8
·
verified ·
1 Parent(s): f79a146

Delete scanner.py

Browse files
Files changed (1) hide show
  1. scanner.py +0 -108
scanner.py DELETED
@@ -1,108 +0,0 @@
1
- # ════════════════════════════════════════
2
- # FILE: scanner.py
3
- # ════════════════════════════════════════
4
-
5
- import asyncio
6
- import random
7
- import re
8
- from datetime import datetime, timezone
9
- from curl_cffi.requests import AsyncSession
10
- import config
11
-
12
- async def check_fragment_status(session: AsyncSession, word: str, semaphore: asyncio.Semaphore, job_id: str) -> dict:
13
- async with semaphore:
14
- retries = 0
15
- status = "Unknown"
16
- while retries <= config.MAX_RETRIES:
17
- proxy_dict = None
18
- if config.PROXY_POOL:
19
- proxy_str = random.choice(config.PROXY_POOL)
20
- proxy_dict = {"http": proxy_str, "https": proxy_str}
21
-
22
- try:
23
- url = f"https://fragment.com/username/{word}"
24
- response = await session.get(url, timeout=10, proxies=proxy_dict)
25
- text = response.text
26
-
27
- if response.status_code in [429, 403, 503] or "Just a moment..." in text or 'id="challenge-running"' in text:
28
- await asyncio.sleep(2 ** retries)
29
- retries += 1
30
- continue
31
-
32
- if response.status_code in [200, 404]:
33
- final_url = str(response.url)
34
- if "/?query=" in final_url:
35
- pattern = rf'<div class="table-cell-value tm-value">@{re.escape(word)}</div>(.*?)</tr>'
36
- match = re.search(pattern, text, re.DOTALL)
37
- if match:
38
- status_html = match.group(1)
39
- if "tm-status-available" in status_html:
40
- status = "Available"
41
- elif "tm-status-taken" in status_html:
42
- status = "Taken"
43
- elif "tm-status-unavail" in status_html:
44
- status = "Unavailable"
45
- else:
46
- status = "Unknown Status Fragment"
47
- else:
48
- status = "Not Found in Search Results"
49
- else:
50
- match = re.search(r'<span class="tm-section-header-status[^>]*">(.*?)</span>', text)
51
- if match:
52
- status = re.sub(r'<[^>]+>', '', match.group(1)).strip()
53
- elif "Someone already claimed this username" in text:
54
- status = "Taken"
55
- elif "is currently not for sale" in text:
56
- status = "Unavailable"
57
- else:
58
- status = f"Unknown: {final_url.replace('https://fragment.com', '')}"
59
- break
60
- else:
61
- status = f"Failed: HTTP {response.status_code}"
62
- retries += 1
63
- await asyncio.sleep(1)
64
-
65
- except Exception as e:
66
- retries += 1
67
- await asyncio.sleep(1)
68
- status = f"Error: {type(e).__name__}"
69
-
70
- if retries > config.MAX_RETRIES and status.startswith("Unknown"):
71
- status = "BLOCKED: Max Retries Hit"
72
-
73
- await asyncio.sleep(config.DELAY_BETWEEN_REQUESTS)
74
-
75
- return {
76
- "Username": word,
77
- "Status": status,
78
- "Timestamp": datetime.now(timezone.utc).isoformat(),
79
- "JobID": job_id
80
- }
81
-
82
- async def run_scan(words: list[str], job_id: str, stop_event: asyncio.Event, progress_callback):
83
- semaphore = asyncio.Semaphore(config.WORKERS)
84
-
85
- async with AsyncSession(impersonate="chrome110") as session:
86
- completed_so_far = 0
87
- total = len(words)
88
-
89
- for i in range(0, total, config.BATCH_SIZE):
90
- if stop_event.is_set():
91
- return
92
-
93
- batch_words = words[i:i + config.BATCH_SIZE]
94
- tasks = [
95
- asyncio.create_task(check_fragment_status(session, word, semaphore, job_id))
96
- for word in batch_words
97
- ]
98
-
99
- batch_results = []
100
- for coro in asyncio.as_completed(tasks):
101
- res = await coro
102
- batch_results.append(res)
103
- completed_so_far += 1
104
-
105
- if stop_event.is_set():
106
- return
107
-
108
- await progress_callback(completed_so_far, total, batch_results)