欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python基于PycURL自動處理cookie的方法

 更新時間:2015年07月25日 12:15:03   作者:Sephiroth  
這篇文章主要介紹了Python基于PycURL自動處理cookie的方法,實例分析了Python基于curl操作cookie的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了Python基于PycURL自動處理cookie的方法。分享給大家供大家參考。具體如下:

import pycurl
import StringIO
url = "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 <name=string/file> 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 <file> 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程序設計有所幫助。

相關文章

最新評論