response是响应的对象 response.text # 返回的是字节,数据的原内容response.content # 返回的是字符串,默认是utf-8解码 重定向:浏览器发送请求,服务器返回重定向的状态码和location,没有响应体。浏览器会自动再发送给location的url一次请求,才 ...
分类:
其他好文 时间:
2019-01-22 21:52:11
阅读次数:
185
简介 1、GET请求 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # 1、无参数实例 import requests ret = requests.get('https://github.com/timeline.json') print r ...
分类:
编程语言 时间:
2019-01-22 21:47:14
阅读次数:
204
爬虫中常见操作 [TOC] 一、requests的用法 1、常见方法 (1)params 直接将参数放在 params中 会自动进行url编码 (2)post方法 其他参数与get一致,请求体放在data中 2、session方法 该方法 自动保存和提交 cookie 3、其他方法 二、指定响应体编 ...
分类:
其他好文 时间:
2019-01-22 21:46:41
阅读次数:
249
``` import requests import re
ret = requests.get('https://github.com/login')
print(ret.headers)
cookies = ret.cookies
authenticity_token=re.findall('n... ...
分类:
其他好文 时间:
2019-01-22 21:45:26
阅读次数:
323
前面用篇专门讲了requests实现接口的参数关联案例,这里直接转化成locust脚本就行了 ...
分类:
其他好文 时间:
2019-01-22 19:47:24
阅读次数:
223
#!/usr/bin/env python # -*- coding: utf-8 -*- import requests headers = {'uuid': '5cb572b7-c0a7-4d90-81a4-58d24f3e2949'} cookies={'Cookie':'pinId=9-Qi... ...
分类:
编程语言 时间:
2019-01-22 19:11:55
阅读次数:
371
import requests r = requests.get("http://www.cnblogs.com/yoyoketang/", timeout=1) # 设置超时 print(r.elapsed) print(r.elapsed.total_seconds()) print(r.ela ...
分类:
其他好文 时间:
2019-01-22 17:38:41
阅读次数:
365
# coding:utf-8import requests# 禁用安全请求警告from requests.packages.urllib3.exceptions import InsecureRequestWarningrequests.packages.urllib3.disable_warnin ...
分类:
Web程序 时间:
2019-01-22 17:38:03
阅读次数:
223
# coding:utf-8import requests# 请求头headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0" }s = requests. ...
分类:
其他好文 时间:
2019-01-22 16:27:33
阅读次数:
207
paylod = {"xx":"xxxx", "xx":"xxx"} r = requests.post("xxxxxxxxxx", data=paylod) print(r.text) --json paylod = {"xx":"xxxx", "xx":"xxx"} data_json = du ...
分类:
其他好文 时间:
2019-01-22 15:58:10
阅读次数:
206