Commit 6548040a authored by Edvard Rejthar's avatar Edvard Rejthar

funguje novy google safebrowsing syntaxe

parent 10048ff6
This diff is collapsed.
......@@ -76,12 +76,16 @@ class Domains:
#
# @param format 'bool' Vraci bool True/False/None, nebo 'attr' vraci int "1"/"0"/"" pro atribut
def isSuspicious(domain, output='bool'):
contents = urllib.request.urlopen('http://www.google.com/safebrowsing/diagnostic?site=' + domain).read().decode("utf-8")
with open("debugsf.tmp","a") as f:
f.write(contents + "\n\n")
if "Site is listed as suspicious" in contents:
#contents = urllib.request.urlopen('http://www.google.com/safebrowsing/diagnostic?site=' + domain).read().decode("utf-8")
#with open("debugsf.tmp","a") as f:
# f.write(contents + "\n\n")
#if "Site is listed as suspicious" in contents:
#elif "This site is not currently listed as suspicious." in contents:
import requests, re, json
r = requests.get("http://www.google.com/safebrowsing/diagnostic?output=jsonp&site=" + domain, timeout=5)
if '"listed"' in r.text:
return True if output == 'bool' else "1"
elif "This site is not currently listed as suspicious." in contents:
if '"unlisted"' in r.text: # vratilo to alespon neco rozumneho
return False if output == 'bool' else "0"
else:
return None if output == 'bool' else ""
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment