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


Posted in Python onJuly 25, 2015

本文实例讲述了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 排列组合之itertools
Mar 20 Python
python中getattr函数使用方法 getattr实现工厂模式
Jan 20 Python
python中assert用法实例分析
Apr 30 Python
小米5s微信跳一跳小程序python源码
Jan 08 Python
Python利用matplotlib.pyplot绘图时如何设置坐标轴刻度
Apr 09 Python
python f-string式格式化听语音流程讲解
Jun 18 Python
opencv python Canny边缘提取实现过程解析
Feb 03 Python
Python通过两个dataframe用for循环求笛卡尔积
Apr 29 Python
Python应用实现双指数函数及拟合代码实例
Jun 19 Python
解决tensorflow 释放图,删除变量问题
Jun 23 Python
Python高并发和多线程有什么关系
Nov 14 Python
pytorch 权重weight 与 梯度grad 可视化操作
Jun 05 Python
Python基于PycURL实现POST的方法
Jul 25 #Python
Python实现对excel文件列表值进行统计的方法
Jul 25 #Python
Python自动扫雷实现方法
Jul 25 #Python
Python导出DBF文件到Excel的方法
Jul 25 #Python
Python实现的RSS阅读器实例
Jul 25 #Python
Python获取央视节目单的实现代码
Jul 25 #Python
Python实现将DOC文档转换为PDF的方法
Jul 25 #Python
You might like
全国FM电台频率大全 - 7 吉林省
2020/03/11 无线电
自制短波长线天线频率预选器 - 成功消除B2K之流的镜像
2021/03/02 无线电
PHP生成静态页面详解
2006/11/19 PHP
PHP has encountered an Access Violation at 7C94BD02解决方法
2009/08/24 PHP
PHP中的string类型使用说明
2010/07/27 PHP
php实现比较两个字符串日期大小的方法
2015/05/12 PHP
PHP中的命名空间详细介绍
2015/07/02 PHP
PHP创建/删除/复制文件夹、文件
2016/05/03 PHP
Python中使用django form表单验证的方法
2017/01/16 PHP
表单提交前触发函数返回true表单才会提交
2014/03/11 Javascript
js判断移动端是否安装某款app的多种方法
2015/12/18 Javascript
简单的JS时钟实例讲解
2016/01/13 Javascript
JS匿名函数实例分析
2016/11/26 Javascript
简单实现jQuery弹幕效果
2017/05/06 jQuery
vue实现百度搜索下拉提示功能实例
2017/06/14 Javascript
vue 实现 ios 原生picker 效果及实现思路解析
2017/12/06 Javascript
node下使用UglifyJS压缩合并JS文件的方法
2018/03/07 Javascript
在angular 6中使用 less 的实例代码
2018/05/13 Javascript
vue引入js数字小键盘的实现代码
2018/05/14 Javascript
JavaScript学习教程之cookie与webstorage
2019/06/23 Javascript
微信小程序前端promise封装代码实例
2019/08/24 Javascript
vue.js购物车添加商品组件的方法
2019/09/17 Javascript
[02:43]DOTA2英雄基础教程 德鲁伊
2014/01/13 DOTA
[01:09]DOTAPLUS——DOTA2的新时代
2018/04/04 DOTA
python实现zencart产品数据导入到magento(python导入数据)
2014/04/03 Python
python中list列表的高级函数
2016/05/17 Python
Jupyter中直接显示Matplotlib的图形方法
2018/05/24 Python
python区分不同数据类型的方法
2019/10/14 Python
Python多线程Threading、子线程与守护线程实例详解
2020/03/24 Python
Python气泡提示与标签的实现
2020/04/01 Python
奥巴马就职演讲稿
2014/05/15 职场文书
建筑安全标语
2014/06/07 职场文书
毕业论文致谢部分怎么写
2015/05/14 职场文书
只需要12页,掌握撰写一流商业计划书的技巧
2019/05/07 职场文书
Java9新特性对HTTP2协议支持与非阻塞HTTP API
2022/03/16 Java/Android
不负正版帝国之名 《重返帝国》引领SLG手游制作新的标杆
2022/04/07 其他游戏