1: 发送带 cookie 的 请求

resp = requests.get(self.url_item_list_first_page, cookies=self.cookies)
>>> url = 'http://httpbin.org/cookies'
>>> cookies = dict(cookies_are='working') >>> r = requests.get(url, cookies=cookies)
>>> r.text
'{"cookies": {"cookies_are": "working"}}'
>>> jar = requests.cookies.RequestsCookieJar()
>>> jar.set('tasty_cookie', 'yum', domain='httpbin.org', path='/cookies')
>>> jar.set('gross_cookie', 'blech', domain='httpbin.org', path='/elsewhere')
>>> url = 'http://httpbin.org/cookies'
>>> r = requests.get(url, cookies=jar)
>>> r.text
'{"cookies": {"tasty_cookie": "yum"}}'

官网源码: http://docs.python-requests.org/zh_CN/latest/user/quickstart.html#cookie

python requests 包 使用的更多相关文章

  1. 关于python requests 包跑ssl的设置 和 charles相关抓包的问题

    由于在测试服务器上测试东西都是https,然后最近又在和大神一起开发openapi,api写好当然是要测试的 python上测试接口最好用的莫过于requests模块了.但是 我还从来没有用reque ...

  2. 关于python requests包新版本设置代理的问题

    在更新了requests包之后,发现我电脑上的charles工具无法再成功抓取到数据包.百度了半年都没有找到原因. 然后 我使用了 google 查到了 charles的最新的文档发现.需要设置代理, ...

  3. python requests包的基本使用

    Requests 安装requests模块: D:\Install\Python36>pip3 install requests 请求方式 #coding:utf-8 import reques ...

  4. java 实现类似于python requests包的Session类,自动管理cookie。

    1.在py中requests.post()和get()函数都是在那个函数内部里面自动生成了一个Session类的实例,所以requests,post和get函数要想干登陆后才能干的事情,需要添加coo ...

  5. Python+Requests接口测试教程(1):Fiddler抓包工具

    本书涵盖内容:fiddler.http协议.json.requests+unittest+报告.bs4.数据相关(mysql/oracle/logging)等内容.刚买须知:本书是针对零基础入门接口测 ...

  6. 更新 requests 包之后报 has no attribute '__getitem__' 的错

    翻代码的时候看到段一年多前用 python 写的下载图片站图片的代码. 测试下看还能不能下到图片,结果发现跑不起来了,报了个如下的错误: TypeError: 'instancemethod' obj ...

  7. 浅谈 Requests包

    浅谈 Requests包 一:Requests包是做什么的? 简单地说,是用python处理HTTP的一个包. 它的标志也非常有气质,是一个双蛇杖,按照官方的说法,一条蛇代表client,一条代表se ...

  8. 利用cookies+requests包登陆微博,使用xpath抓取目标用户的用户信息、微博以及对应评论

    本文目的:介绍如何抓取微博内容,利用requests包+cookies实现登陆微博,lxml包的xpath语法解析网页,抓取目标内容. 所需python包:requests.lxml 皆使用pip安装 ...

  9. 转载:python + requests实现的接口自动化框架详细教程

    转自https://my.oschina.net/u/3041656/blog/820023 摘要: python + requests实现的接口自动化框架详细教程 前段时间由于公司测试方向的转型,由 ...

随机推荐

  1. cannot import name '_validate_lengths' from 'numpy.lib.arraypad'

    在Anaconda下新配置了tensorflow环境,结果在引入skimage 包时报错,错误提示from numpy.lib.arraypad import _validate_lengths,找不 ...

  2. 117. Populating Next Right Pointers in Each Node II 计算右边的附属节点

    [抄题]: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNod ...

  3. Hamming Distance二进制距离

    [抄题]: The Hamming distance between two integers is the number of positions at which the correspondin ...

  4. linux环境下搭建osm_web服务器一(Postgresql配置及osm2pgsql原始数据导入):

    Postgresql配置及osm2pgsql原始数据导入 2012年,Ubuntu 12.04LTS发布,又一个长效支持版,我们又该更新OpenStreetMap服务器了,这次,将详细在博客中记录配置 ...

  5. 实践作业4---DAY3阶段二。

    第二阶段是用户调研,我们小组选择了一个5班的同学,作为采访对象.采访比较详实,但是样本太少,不太有说服力. 具体采访详情如下: 问:请问您使用喜欢发表Blog么? 答:肯定有啊. 问:都用什么网站发表 ...

  6. How do I avoid capturing self in blocks when implementing an API?

    Short answer Instead of accessing self directly, you should access it indirectly, from a reference t ...

  7. Android studio Maven仓库使用

    原文:How to distribute your own Android library through jCenter and Maven Central from Android Studio ...

  8. 编写高质量代码改善C#程序的157个建议——建议88:并行并不总是速度更快

    建议88:并行并不总是速度更快 并行所带来的后台任务及任务的管理,都会带来一定的开销,如果一项工作本来就能很快完成,或者说循环体很小,那么并行的速度也许会比非并行要慢. 看这样一个例子,我们比较在同步 ...

  9. 学习python4

    文件系统实现文件的增删改查 UnicodeDecodeError: 'gbk' codec can't decode byte 0x9a in position 8: illegal multibyt ...

  10. http-bio-8080"-exec-6

    现象如下:   Tomcat7启动后,后台抛出如下异常,前台一直无法登陆   Exception in thread ""http-bio-8080"-exec-6&qu ...