[Tutor] python2 vs python3 urllib
Alan Gauld
alan.gauld at btinternet.com
Sun Apr 24 01:42:50 CEST 2011
"pierre dagenais" <eq742 at ncf.ca> wrote
> sock = urllib.urlopen("http://diveintopython.org/")
> AttributeError: 'module' object has no attribute 'urlopen'
>
> What is the proper syntax in version 3?
using help() shows that urllib has become a package in v3.
The request module looked promising and sure enough
>>> import urllib.request as req
>>> help(req)
shows:
urlopen(url, data=None, timeout=<object object>)
urlretrieve(url, filename=None, reporthook=None, data=None)
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list