-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTorSearch.py
49 lines (42 loc) · 1.57 KB
/
TorSearch.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
import requests
import random, string
import re
from sys import exit
print("""\033[95m
_______ _____ _
|__ __| / ____| | |
| | ___ _ _| (___ ___ __ _ _ __ ___| |__ ___ _ __
| |/ _ \| '__\___ \ / _ \/ _` | '__/ __| '_ \ / _ \ '__|
| | (_) | | ____) | __/ (_| | | | (__| | | | __/ |
|_|\___/|_| |_____/ \___|\__,_|_| \___|_| |_|\___|_|
\033[94m telegram : @linuxdebain
""")
search = input("Enter your search : ")
try:
number = int(input("how many websits you want? "))
except Exception as err:
print("\033[0;31;40m" , err)
exit(0)
if " " in search:
search = search.replace(" ", "+")
url = f"https://ahmia.fi/search/?q={search}"
with open("user-agents.txt", "r+") as a: # This file include many user agents for Not get banned from ahmia.fi
users = random.choice(a.readlines()).strip()
header = {
"User-Agent": users
}
results_limt = number
result_collected = 0
webs = requests.get(url, headers=header).text
reg = "\w+\.onion"
data = re.findall(reg, webs)
filename = ''.join(random.choice(string.ascii_letters + string.digits)for i in range(5))
data = list(dict.fromkeys(data))
with open(f"{filename}.txt", "a+") as f:
for i in data:
if result_collected >= results_limt:
break
i = i + "\n"
f.write(i)
result_collected += 1
print(f"\033[0;31;40m \nCompleted, saved in {filename}.txt")