I am trying to use the google web risk API ( beta) with my python code . Please see the sample code:-
URI='http://www.amazongroupco.org' # bad url
key='key=<mykey>'
threat='&threatTypes=MALWARE'
queryurl='https://webrisk.googleapis.com/v1beta1/uris:search?'
requeststring=queryurl+key+threat
header={"Content-Type":"application/json"}
payload = {'uri':URI }
try:
req = requests.get(requeststring, headers=header, params=payload)
print(req.url)
if (req.status_code == 200):
print(req)
else:
print(" ERROR:",req)
except Exception as e:
print(" Google API returned error:",e, req.url)
The above code always returns successful request status code "Response [200] OK" with an empty jason response {}. The fact that it is an malicious site , I was expecting it to return something in the jason response. I tried it with other malicious sites as well but I get the same response - empty jason object with a status 200 OK.
Am I missing something ?.
I understand that some sites may not have malware but are social engineering sites which is another kind of threattype. Therefore i am wondering if there is an general purpose all-in-all threatTypes attribute I can use which will return a jason object no matter what the threat is as long as it is a Threat.
Just a side note that anyone trying this should have an GCP account to generate a key.
Any guidance here will be much appreciated.