The examples in this article describe how Python automatically processes cookies based on Pycurl. Share to everyone for your reference. Specific as follows:
Import Pycurlimport Stringiourl = "http://www.google.com/" CRL = Pycurl. Curl () crl.setopt (Pycurl. verbose,1) crl.setopt (Pycurl. Followlocation, 1) crl.setopt (Pycurl. Maxredirs, 5) CRL.FP = Stringio.stringio () crl.setopt (Pycurl. URL, url) crl.setopt (CRL). Writefunction, Crl.fp.write) # Option-b/--cookie
cookie string or file to read the cookie from# note:must be a String, not a file object.crl.setopt (Pycurl. Cookiefile, "Cookie_file_name") # Option-c/--cookie-jar
Write cookies to this file after operation# Note:mu St is a string, not a file object.crl.setopt (Pycurl. Cookiejar, "Cookie_file_name") Crl.perform () print crl.fp.getvalue ()
Hopefully this article will help you with Python programming.