-2

Is their any way to check particular URL in web browser

I tried in this below format as well

print(webbrowser.get('windows-default').open_new_tab('https://facebook.com) and the output is True but also open the url.

Code :

import webbrowser

urls = ['facebook.com','https://instagram.com','http://twitter.com']
for i in urls:
    if webbrowser.get('windows-default').open_new_tab(i) == False:
        webbrowser.get('windows-default').open_new_tab('https://'+i)
    elif webbrowser.get('windows-default').open_new_tab('https://'+i) == False:
        webbrowser.get('windows-default').open_new_tab('http://'+i)
codeholic24
  • 955
  • 4
  • 22
Abrham
  • 25
  • 4

1 Answers1

0

You can the validators! package:

>>> import validators
>>> validators.url("http://google.com")
True
>>> validators.url("http://google")
ValidationFailure(func=url, args={'value': 'http://google', 'require_tld': True})
>>> if not validators.url("http://google"):
...     print "not valid"
... 
not valid
>>>