2

When trying to visit some website that contain some malicious content, browsers such as Firefox , Google Chrome or Internet Explorer display a message like this one underlying it is unsafe to browse the website in question, as shown on this picture:

enter image description here

I am using Python with Seleinum to launch a websites (on windows xp) in Firefox, Google Chrome and Internet Explorer: in the case the website is declared unsafe by one of these browsers: is there any method to retrieve this information from the browser using Python ? Any idea is very welcome.

1 Answers1

2

If you want to test whether a web-site is "flagged" as dangerous to use, you don't need selenium at all. Make a request to the Google Safebrowsing through their lookup API:

Safe Browsing is a Google service that enables applications to check URLs against Google's constantly updated lists of suspected phishing and malware pages.

And, of course, there is a python wrapper (API key can be generated here):

>>> key = 'your own key'
>>> from safebrowsinglookup import SafebrowsinglookupClient
>>> client = SafebrowsinglookupClient(key)

>>> client.lookup('http://addonrock.ru/Debugger.js')
{'http://addonrock.ru/Debugger.js': 'malware'}

>>> client.lookup('http://google.com')
{'http://google.com': 'ok'}
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • 1
    Dear Alexandre, in reality this question was my serious problem, I asked it before the one you answered last night. But since no one answsered me, I wanted to resolve this problem by taking an other approach, so I asked the question you answered last night. The second part of your answer was the one I needed here also. So my whole problem is solved thanks to You. The minimum I have to do is to reward you all the points I have by setting a bounty here tomorrow,as a respect for your positive and generous intellectual attitude. Regards. –  Jul 31 '14 at 07:01
  • 1
    Just a remark, if I may, I get always this output `{site_to_try':'error'}` whatever the site I try. Note that I use Python 3.4, so after installing the Python wrapper, I had to change its some lines of its code because it was written in Python 2 aparently. –  Jul 31 '14 at 08:44
  • I tested the same code using Pythong 2 (so I did not change anything to the wrapper) on Ubuntu, but I get exactly the same message even if I jsut try http://www.google.com. Something is wrong with this wrapper ? –  Jul 31 '14 at 09:48
  • it is a `KeyError` after some test I did (http://stackoverflow.com/questions/25054946/google-safebrowsing-api-always-getting-an-error-in-python) . But I run it with the valid key –  Jul 31 '14 at 12:55
  • 1
    @Begueradj thanks for the information, sorry, I haven't noticed your python3-only requirement. Glad it helped! – alecxe Jul 31 '14 at 13:48
  • @Begueradj and do not worry about the bounty - these are your points and you deserve them by asking good quality questions. – alecxe Jul 31 '14 at 15:21