ValueError: unknown url type in urllib2, though the url is fine if opened in a browser
When you enter a URL in a browser without the protocol, it defaults to HTTP. urllib2
won't make that assumption for you; you need to prefix it with http://
.
You have to use a complete URL including the protocol, not just specify a host name.
The correct URL would be http://www.tattoo-cover.co.uk/
.
You can use the method urlparse
from urllib
(Python 3) to check the presence of an addressing scheme (http, https, ftp) and concatenate the scheme in case it is not present:
In [1]: from urllib.parse import urlparse ..: ..: url = 'www.myurl.com' ..: if not urlparse(url).scheme: ..: url = 'http://' + url ..: ..: urlOut[1]: 'http://www.myurl.com'