-
Notifications
You must be signed in to change notification settings - Fork 7
/
searcher.py
68 lines (66 loc) · 1.72 KB
/
searcher.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
65
66
67
68
import _thread
from urllib import request
import time
import tkinter as tk
import random
ban=['Bad Gateway','Internal Server Error','No interface is running right now','"auth_required": true']
requires=['txt2img']
tot=0
def Bing(lsbox,url,f):
global tot
global timeset
# print(id)
tot+=1
try:
rq=request.Request(url)
rp=request.urlopen(rq)
rep=rp.read().decode('utf-8')
# print(rep)
for ele in ban:
if ele in rep:
tot-=1
return
for ele in requires:
if ele not in rep:
tot-=1
return
if lsbox!=None:
lsbox.insert(tk.END,"Find "+url)
f.write(url+'\n')
f.flush()
tot-=1
return
except:
tot-=1
return
def Search(flag,lsbox=None,low=10000,high=30000,maxtot=1000):
global timeset
timeset=0
if lsbox!=None:
lsbox.insert(tk.END,"Searching from {0} to {1}".format(low,high))
try:
f=open("web_list.txt",'r',encoding='utf-8')
lines=f.readlines()
f.close()
except:
lines=[]
f=open("web_list.txt",'a',encoding='utf-8')
queue=list(range(low,high+1))
random.shuffle(queue)
for i in queue:
if(flag[0]):
break
while tot>maxtot:
continue
# print(i)
url="https://{0}.gradio.app/".format(i)
if url in lines:
continue
_thread.start_new_thread(Bing,(lsbox,url,f))
time.sleep(0.005)
time.sleep(0.5)
while tot>0:
continue
f.close()
if lsbox!=None:
lsbox.insert(tk.END,"Searching Over")