-
Notifications
You must be signed in to change notification settings - Fork 10
/
bing.py
123 lines (99 loc) · 4.53 KB
/
bing.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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import urllib2
import json
import honeypotconfig
from BeautifulSoup import BeautifulSoup
def searchBing(keyword):
queryBingFor = "'%s'" %keyword #"'google fibre'" # the apostrophe's required as that is the format the API Url expects.
quoted_query = urllib.quote(queryBingFor)
account_key = "Unolx7kLAlLp1NSwmPyis9df+ecjQeN9pqGe57sW/D8="
rootURL = "https://api.datamarket.azure.com/Bing/Search/"
searchURL = rootURL + "Web?$format=json&Query=" +quoted_query+ "&$top=1&$skip="+str(honeypotconfig.starturl)
username="masood.mansoori@live.com"
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, searchURL,username,account_key)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
# authhandler = urllib2.HTTPDigestAuthHandler(password_mgr)
# opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
readURL = urllib2.urlopen(searchURL).read()
response_data = readURL
json_result = json.loads(response_data)
result_list = json_result['d']['results']
searchresult=open("list/searchresult.txt", "w")
for i in result_list:
print i['Url']
searchresult.write(i['Url']+"\n")
searchresult.close()
nextsearch=honeypotconfig.starturl+50
queryBingFor = "'%s'" %keyword #"'google fibre'" # the apostrophe's required as that is the format the API Url expects.
quoted_query = urllib.quote(queryBingFor)
account_key = "Unolx7kLAlLp1NSwmPyis9df+ecjQeN9pqGe57sW/D8="
rootURL = "https://api.datamarket.azure.com/Bing/Search/"
searchURL = rootURL + "Web?$format=json&Query=" +quoted_query+ "&$top=50&$skip="+str(nextsearch)
username="masood.mansoori@live.com"
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, searchURL,username,account_key)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
# authhandler = urllib2.HTTPDigestAuthHandler(password_mgr)
# opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
readURL = urllib2.urlopen(searchURL).read()
response_data = readURL
json_result = json.loads(response_data)
result_list = json_result['d']['results']
searchresult=open("list/searchresult.txt", "a")
for i in result_list:
print i['Url']
searchresult.write(i['Url']+"\n")
searchresult.close()
nextsearch=honeypotconfig.starturl+100
queryBingFor = "'%s'" %keyword #"'google fibre'" # the apostrophe's required as that is the format the API Url expects.
quoted_query = urllib.quote(queryBingFor)
account_key = "Unolx7kLAlLp1NSwmPyis9df+ecjQeN9pqGe57sW/D8="
rootURL = "https://api.datamarket.azure.com/Bing/Search/"
searchURL = rootURL + "Web?$format=json&Query=" +quoted_query+ "&$top=50&$skip="+str(nextsearch)
username="masood.mansoori@live.com"
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, searchURL,username,account_key)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
# authhandler = urllib2.HTTPDigestAuthHandler(password_mgr)
# opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
readURL = urllib2.urlopen(searchURL).read()
response_data = readURL
json_result = json.loads(response_data)
result_list = json_result['d']['results']
searchresult=open("list/searchresult.txt", "a")
for i in result_list:
print i['Url']
searchresult.write(i['Url']+"\n")
searchresult.close()
nextsearch=honeypotconfig.starturl+150
queryBingFor = "'%s'" %keyword #"'google fibre'" # the apostrophe's required as that is the format the API Url expects.
quoted_query = urllib.quote(queryBingFor)
account_key = "Unolx7kLAlLp1NSwmPyis9df+ecjQeN9pqGe57sW/D8="
rootURL = "https://api.datamarket.azure.com/Bing/Search/"
searchURL = rootURL + "Web?$format=json&Query=" +quoted_query+ "&$top=5&$skip="+str(nextsearch)
username="masood.mansoori@live.com"
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, searchURL,username,account_key)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
# authhandler = urllib2.HTTPDigestAuthHandler(password_mgr)
# opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
readURL = urllib2.urlopen(searchURL).read()
response_data = readURL
json_result = json.loads(response_data)
result_list = json_result['d']['results']
searchresult=open("list/searchresult.txt", "a")
for i in result_list:
print i['Url']
searchresult.write(i['Url']+"\n")
searchresult.close()