Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Need urllib.urlretrieve and urllib2.OpenerDirector together

Reply
Thread Tools

Need urllib.urlretrieve and urllib2.OpenerDirector together

 
 
Juanlu_001
Guest
Posts: n/a
 
      12-26-2010
Hello everyone. I'm writing a script in Python 2.7 which uses a
urllib2.OpenerDirector instance via urllib2.build_opener() to take
advantage of the urllib2.HTTPCookieProcessor class, because I need to
store and re-send the cookies I get:

opener =
urllib2.build_opener(urllib2.HTTPCookieProcessor(c ookielib.CookieJar()))

However, after making several requests and moving the cookies around,
eventually I need to retrieve a list of URLs. I wanted to use
urllib.urlretrieve() because I read it downloads the file in chunks,
but I cannot because I need to carry my cookies on the request and
urllib.urlretrieve() uses a urllib.URLOpener, which doesn't have
support for cookie handlers like OpenerDirector has.

I want to know the reason of this strange way of splitting
functionality, and how can I achieve my goal.

Thank you in advance!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to redirect both std out and err to a file together and still err to a separate file qwertmonkey@syberianoutpost.ru Java 0 08-29-2012 09:07 AM
trying to redirect both std out and err to a file together and still err to a separate file qwertmonkey@syberianoutpost.ru Java 1 08-29-2012 07:28 AM
trying to redirect both std out and err to a file together and still err to a separate file qwertmonkey@syberianoutpost.ru Java 1 08-29-2012 12:10 AM
Need help bringing select array lines together Paul Ruby 11 05-27-2011 04:53 AM
Need to concatenate all files in a dir together into one file and read the first 225 characters from each file into another file. Tony Perl Misc 5 04-19-2004 03:28 PM



Advertisments