Skip to content

Commit da3a0d1

Browse files
committedOct 12, 2014
Updated google lookup api to work without any 3rd party module
1 parent 24c62ef commit da3a0d1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎google.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Author: lnxg33k
33
# @Date: 2014-10-08 03:47:26
44
# @Last Modified by: lnxg33k
5-
# @Last Modified time: 2014-10-12 17:35:21
5+
# @Last Modified time: 2014-10-12 20:35:28
66

77
"""
88
In order to interact with the Safe Browsing lookup server,
@@ -16,7 +16,7 @@
1616
5. Click on Create new key and create a browser or server key.
1717
"""
1818

19-
from requests import request
19+
from urllib2 import Request, urlopen
2020
from sys import argv
2121
from json import dumps
2222

@@ -37,14 +37,14 @@ def lookUp(domains=[]):
3737
result = {}
3838
chunked_domains = chunks(domains)
3939
for chunk in chunked_domains:
40+
data = "%s\n%s" % (len(chunk), "\n".join(chunk))
4041
try:
41-
r = request(
42-
'POST',
43-
url, data="%s\n%s" % (len(chunk), "\n".join(chunk))
44-
)
45-
if r.status_code == 200:
42+
req = Request(url, data)
43+
r = urlopen(req)
44+
if r.code == 200:
4645
result.update(dict(zip(
47-
chunk, map(lambda n: {'google': n}, r.content.splitlines()))
46+
chunk,
47+
map(lambda n: {'google': n}, map(str.strip, r.readlines())))
4848
))
4949
except:
5050
pass

0 commit comments

Comments
 (0)