Skip to content Skip to sidebar Skip to footer

Logging In And Using Cookies In Pycurl

I need to download a file that is on a password protected page. To get to the page manually I first have to authenticate via an ordinary login page. I want to use curl to fetch t

Solution 1:

I believe Curl will store the cookies but you need to use them explicitly. I've only ever used the command line interface for this though. Scanning the documentation I think you might want to try:

C.setopt(pycurl.COOKIEFILE, 'cookie.txt')

(before the second request)

Solution 2:

wds is right on.

for your further edification, the available options are based on those at http://curl.haxx.se/libcurl/c/curl_easy_setopt.html (see the section on cookie shortcuts).

a 500 is an internal server error...hard to be sure whether this can be blamed on your script without knowing more information about what's going on here. you could be failing to pass other data the page is expecting (unrelated to cookies) for all we know (and they have not implemented graceful error handling!)

jb

Post a Comment for "Logging In And Using Cookies In Pycurl"