Python基于PycURL自动处理cookie的方法,pythonpycurl
Python基于PycURL自动处理cookie的方法,pythonpycurl
本文实例讲述了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程序设计有所帮助。
相关内容
- Python实现截屏的函数,python截屏函数
- Python实现简单的代理服务器,python代理服务器
- Python基于有道实现英汉字典功能,python英汉字典
- Python实现模拟登录及表单提交的方法,python表单
- Python中Django框架利用url来控制登录的方法,pythondjango
- Python基于动态规划算法计算单词距离,python算法
- Python计算已经过去多少个周末的方法,python已经过去
- 详解Python的Django框架中的中间件,pythondjango
- Python字符串转换成浮点数函数分享,python点数
- 通过mod_python配置运行在Apache上的Django框架,mod_pythond
评论关闭