Skip to content

Commit f27d2e6

Browse files
committed
新增requests测试
1 parent 0237595 commit f27d2e6

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Requests.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Requests
2+
3+
certifi 已经从 requests 项目中单独提取出来
4+
5+
http://docs.python-requests.org/en/master/
6+
7+
https://certifi.io/en/latest/

test/test_requests.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
4+
"""
5+
@author: zhanghe
6+
@software: PyCharm
7+
@file: test_requests.py
8+
@time: 2017/2/13 下午11:05
9+
"""
10+
11+
import requests
12+
13+
14+
def test_cookie():
15+
"""
16+
测试cookies
17+
:return:
18+
"""
19+
url = 'http://www.baixing.com'
20+
r = requests.get(url)
21+
print r.cookies.items() # [('__city', 'shanghai'), ('__s', '2hpl4if6jromtarou0vcvvtnm4')]
22+
# 清除会话 cookie
23+
r.cookies.clear_session_cookies()
24+
print r.cookies.items() # [('__city', 'shanghai')]
25+
26+
27+
if __name__ == '__main__':
28+
test_cookie()

0 commit comments

Comments
 (0)