Re: mysteries of urllib/urllib2

2007-07-03 Thread Adrian Smith
On Jul 4, 12:42 am, Ben Cartwright <[EMAIL PROTECTED]> wrote: > On Jul 3, 11:14 am, Adrian Smith <[EMAIL PROTECTED]> wrote: > > > > > The following (pinched > > > > from Dive Into Python) seems to work perfectly in Idle, but > > > > falls at the final hurdle when run as a cgi script > > > Put this

Re: mysteries of urllib/urllib2

2007-07-03 Thread O.R.Senthil Kumaran
* Adrian Smith <[EMAIL PROTECTED]> [2007-07-03 08:14:32]: > some access. Apparently there's a way to change the user-agent string > by subclassing urllib's URLopener class, but that's beyond my comfort > zone at present. Read the urllib2 how-to located at ActiveState Documentation pages. That giv

Re: mysteries of urllib/urllib2

2007-07-03 Thread John Nagle
Adrian Smith wrote: > I'm trying to use urllib2 to download a page (I'd rather use urllib, > but I need to change the User-Agent header to look like a browser or > G**gle won't send it to me, the big meanies). The following (pinched > from Dive Into Python) seems to work perfectly in Idle, but fall

Re: mysteries of urllib/urllib2

2007-07-03 Thread Ben Cartwright
On Jul 3, 11:14 am, Adrian Smith <[EMAIL PROTECTED]> wrote: > > > The following (pinched > > > from Dive Into Python) seems to work perfectly in Idle, but > > > falls at the final hurdle when run as a cgi script > > Put this at the top of your cgi script: > > > import cgitb; cgitb.enable() Did you

Re: mysteries of urllib/urllib2

2007-07-03 Thread Adrian Smith
On Jul 3, 11:25 pm, Ben Cartwright <[EMAIL PROTECTED]> wrote: > On Jul 3, 9:43 am, Adrian Smith <[EMAIL PROTECTED]> wrote: > > > The following (pinched > > from Dive Into Python) seems to work perfectly in Idle, but > > falls at the final hurdle when run as a cgi script - can > > anyone suggest any

Re: mysteries of urllib/urllib2

2007-07-03 Thread Ben Cartwright
On Jul 3, 9:43 am, Adrian Smith <[EMAIL PROTECTED]> wrote: > The following (pinched > from Dive Into Python) seems to work perfectly in Idle, but falls at > the final hurdle when run as a cgi script - can anyone suggest > anything I may have overlooked? > > request = urllib2.Request(some_URL) > req

mysteries of urllib/urllib2

2007-07-03 Thread Adrian Smith
I'm trying to use urllib2 to download a page (I'd rather use urllib, but I need to change the User-Agent header to look like a browser or G**gle won't send it to me, the big meanies). The following (pinched from Dive Into Python) seems to work perfectly in Idle, but falls at the final hurdle when r