您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Python基于PycURL自动处理cookie的方法

2024/3/1 17:37:30发布22次查看
本文实例讲述了python基于pycurl自动处理cookie的方法。分享给大家供大家参考。具体如下:
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程序设计有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product