[Tutor] Re: URLs for urllib.urlopen
Bill Bell
bill-bell@bill-bell.hamilton.on.ca
Sat, 30 Jun 2001 08:48:14 -0400
Simon Brunning <SBrunning@trisystems.co.uk> wrote:
> Can someone explain this to me?
>
> PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on
> win32. Portions Copyright 1994-2001 Mark Hammond
> (MarkH@ActiveState.com) - see 'Help/About PythonWin' for further
> copyright information. >>> import urllib, pprint >>> page =
> urllib.urlopen('http://www.python.org') >>> data = page.readlines()
> >>> pprint.pprint(data)
> ['<html><head><title>Error</title></head><body>The parameter is
> incorrect. </body></html>'] >>> page =
> urllib.urlopen('http://www.python.org/') >>> data = page.readlines()
> >>> pprint.pprint(data) ['<HTML>\n',
> '<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. -->\n',
> (... snip)
>
> It appears that urllib requires a trailing slash, but in the examples
> in the effbot's PSL book, he doesn't give one. Any ideas?
Simon, I just executed the lines of code in PythonWin (ActiveState
build 203) without the trailing slash and received the following
>>> import urllib, pprint
>>> page = urllib.urlopen('http://www.python.org')
>>> data = page.readlines()
>>> pprint.pprint(data)
['<HTML>\n',
'<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT
EDIT. -->\n',
'<!-- Thu Jun 28 15:47:15 2001 -->\n',
'<!-- USING HT2HTML 1.1 -->\n',
<SNIP>
Or, IOW, worked for me. Possible transient error at python.org? Or
that you're using an earlier version of Python?
Bill