loading a url using urllib2
- From: "yinglcs@xxxxxxxxx" <yinglcs@xxxxxxxxx>
- Date: 30 Mar 2007 19:21:53 -0700
I have the following code to load a url (address).
When I have a url like this,
http://www.testcom.co.uk/dev_12345/www.cnn.com
i get an error "Failed to open http://www.testcom.co.uk/dev_12345/www.cnn.com".
Is there something wrong with my URL? or something wrong with my code?
Thank you for any help.
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
txheaders = {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5;
Windows NT)'}
try:
print "address", address
print "txdata", txdata
print "txheaders", txheaders
req = Request(address, txdata, txheaders)
handle = urlopen(req)
except IOError, e:
print address
print 'Failed to open %s' % address
data = ""
.
- Follow-Ups:
- Re: loading a url using urllib2
- From: Kushal Kumaran
- Re: loading a url using urllib2
- Prev by Date: Re: Cheeseshop needs mirrors
- Next by Date: how to remove specified cookie in cookie jar?
- Previous by thread: Web-based personal development co. looking for programmers
- Next by thread: Re: loading a url using urllib2
- Index(es):
Relevant Pages
|