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 cookies 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: must be a string, not a file object.crl.setopt(pycurl.cookiejar, cookie_file_name)crl.perform()print crl.fp.getvalue()
希望本文所述对大家的python程序设计有所帮助。
