-
Notifications
You must be signed in to change notification settings - Fork 3
/
search.py
296 lines (276 loc) · 12.1 KB
/
search.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import SearchEngine
import argparse, time
import utils
s = SearchEngine
class System:
def proc_manual(self, engine, query_search, pages, value, name_file, file, proxies):
many_search = 0
page = pages
for res in value:
requests_value = {
"title": res["title"],
"domain": res['data']['domain'],
"url": res['data']['url'],
"description": res['data']['description']
}
utils.write_file(file, query_search, requests_value)
utils.print_value(query_search, requests_value)
while True:
print("1. Next")
print("2. Stop")
inp_next = input("Next or stop (Enter number): ")
print("=========================================")
if inp_next == '1':
print(utils.write_figlet())
# callback function
if engine == "bing":
result = s.bing_search(query_search, page, proxies)
if not result:
many_search += 1
page += 10
elif engine == "google":
result = s.google_search(query_search, page, proxies)
if not result:
many_search += 1
page += 10
elif engine == "duckduckgo":
result = s.duckduckgo_search(query_search, page, proxies)
if not result:
many_search += 1
page += 10
elif engine == "yahoo":
result = s.yahoo_search(query_search, page, proxies)
if not result:
many_search += 1
page += 7
elif engine == "yandex":
result = s.yandex_search(query_search, page, proxies)
if not result:
many_search += 1
page += 1
elif engine == "ask":
result = s.ask_search(query_search, page, proxies)
if not result:
many_search += 1
page += 1
elif engine == "mojeek":
result = s.mojeek_search(query_search, page, proxies)
if not result:
many_search += 1
page += 10
elif engine == "searx":
result = s.searx_search(query_search, page, proxies)
if not result:
many_search += 1
page += 10
if many_search > 2 and not result:
print("Search not found!")
print("\n[*]Stopped: File is in output/" + name_file + ".txt")
break
for res in result:
requests_value = {
"title": res["title"],
"domain": res['data']['domain'],
"url": res['data']['url'],
"description": res['data']['description']
}
utils.write_file(file, query_search, requests_value)
utils.print_value(query_search, requests_value)
elif inp_next == '2':
print("\n[*]Stopped: File is in output/" + name_file + ".txt")
break
else:
print("Invalid input. Please enter '1' or '2'.")
def proc_auto(self, engine, query_search, pages, delay, name_file, file, proxies = False):
for list_query in utils.list_querys():
query = query_search + " " + list_query
if engine == "google":
result = s.google_search(query, pages, proxies)
elif engine == "duckduckgo":
result = s.duckduckgo_search(query, pages, proxies)
elif engine == "bing":
result = s.bing_search(query, pages, proxies)
elif engine == "yahoo":
result = s.yahoo_search(query, pages, proxies)
elif engine == "yandex":
result = s.yandex_search(query, pages, proxies)
elif engine == "ask":
result = s.ask_search(query, pages, proxies)
elif engine == "mojeek":
result = s.mojeek_search(query, pages, proxies)
elif engine == "searx":
result = s.searx_search(query, pages, proxies)
try:
for res in result:
if not res:
print("Search not found!")
break
requests_value = {
"title": res["title"],
"domain": res['data']['domain'],
"url": res['data']['url'],
"description": res['data']['description']
}
utils.write_file(file, query, requests_value)
utils.print_value(query, requests_value)
utils.next_loading()
if not result:
utils.not_result(query)
print("=========================================\n")
time.sleep(int(delay))
except KeyboardInterrupt:
print("\n[*]Stopped: File is in output/" + name_file + ".txt")
break
class Main_manual(System):
global s
def __init__(self, inp_searchEngine="", proxies = False):
self.inp_searchEngine = inp_searchEngine
if self.inp_searchEngine == "1":
self.page = 10
self.inp_query = input("Enter dorking: ")
engine = "google"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "2":
self.page = 10
self.inp_query = input("Enter dorking: ")
engine = "duckduckgo"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "3":
self.page = 10
self.inp_query = input("Enter dorking: ")
engine = "bing"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "4":
self.page = 10
self.inp_query = input("Enter dorking: ")
engine = "yahoo"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "5":
self.page = 1
self.inp_query = input("Enter dorking: ")
engine = "yandex"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "6":
self.page = 1
self.inp_query = input("Enter dorking: ")
engine = "ask"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "7":
self.page = 11
self.inp_query = input("Enter dorking: ")
engine = "mojeek"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "8":
self.page = 10
self.inp_query = input("Enter dorking: ")
engine = "searx"
self.call_search(engine, self.inp_query, self.page, proxies)
elif self.inp_searchEngine == "99":
pass
elif self.inp_searchEngine == "":
pass
else:
print("Your keywoard is wrong!")
def call_search(self, engine, query, page, proxies = False):
name_file = engine + "_" + utils.date_file()
file = open("output/" + name_file + ".txt", "w")
if engine == "google":
result = s.google_search(query, page, proxies)
elif engine == "duckduckgo":
result = s.duckduckgo_search(query, page, proxies)
elif engine == "bing":
result = s.bing_search(query, page, proxies)
elif engine == "yahoo":
result = s.yahoo_search(query, page, proxies)
elif engine == "yandex":
result = s.yandex_search(query, page, proxies)
elif engine == "ask":
result = s.ask_search(query, page, proxies)
elif engine == "mojeek":
result = s.mojeek_search(query, page, proxies)
elif engine == "searx":
result = s.searx_search(query, page, proxies)
self.proc_manual(engine, query, page, result, name_file, file, proxies) #process
file.close()
class Main_auto(System):
global s
def __init__(self, inp_searchEngine = "", inp_time = "", proxies = False):
self.inp_searchEngine = inp_searchEngine
delay = inp_time if inp_time else 4
if self.inp_searchEngine == "1":
self.page = 10
self.inp_query = input("Enter dorking: ")
engine = "google"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "2":
self.page = 10
self.inp_query = input("Enter dorking: ")
engine = "duckduckgo"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "3":
self.page = 1
self.inp_query = input("Enter dorking: ")
engine = "bing"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "4":
self.page = 1
self.inp_query = input("Enter dorking: ")
engine = "yahoo"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "5":
self.page = 0
self.inp_query = input("Enter dorking: ")
engine = "yandex"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "6":
self.page = 1
self.inp_query = input("Enter dorking: ")
engine = "ask"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "7":
self.page = 1
self.inp_query = input("Enter dorking: ")
engine = "mojeek"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "8":
self.page = 1
self.inp_query = input("Enter dorking: ")
engine = "searx"
self.call_search(engine, self.inp_query, self.page, delay, proxies)
elif self.inp_searchEngine == "99":
pass
elif self.inp_searchEngine == "":
pass
else:
print("Your keywoard is wrong!")
def call_search(self, engine, query, page, delay, proxies = False):
name_file = engine + "_" + utils.date_file()
file = open("output/" + name_file + ".txt", "w")
self.proc_auto(engine, query, page, delay, name_file, file, proxies)
file.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-o","--option", help="Give your choice ('manual' or 'auto')", type=str, required=True)
parser.add_argument("-x","--proxy", help="Give your proxy (use http/https) *OPTIONAL", type=str, required=False)
args = parser.parse_args()
if args.option == "manual":
utils.print_choice()
try:
inp_searchEngine = input("Search engine: ")
if inp_searchEngine == "99":
print("Exiting the program...")
else:
Main_manual(inp_searchEngine)
except:
print("Your choice is wrong!")
elif args.option == "auto":
utils.print_choice()
try:
inp_searchEngine = input("Search engine: ")
if inp_searchEngine == "99":
print("Exiting the program...")
else:
inp_time = input("Delay/second(default 4/s): ")
Main_auto(inp_searchEngine, inp_time)
except:
print("Your input is wrong(please check documentation)!")