python爬虫之 Requests库的基本使用
注:requests不是python内置的库,需要单独安装,pip3 install requests
功能详解:
基本GET请求:
import requests response = requests.get(‘http://httpbin.org/get‘) print(response.text)
基本POST请求:
post请求需要添加一个data参数,该参数是由字典构造
import requests data= { ‘name‘:‘miu‘, ‘age‘:24 } response = requests.post(‘http://httpbin.org/post‘,data=data) print(response.text)
响应:
import requests response = requests.get("http://www.baidu.com") print(type(response.status_code),response.status_code) print(type(response.headers),response.headers) print(type(response.cookies),response.cookies) print(type(response.url),response.url) print(type(response.history),response.history)
相关推荐
86193952 2020-10-27
Mynamezhuang 2020-09-18
充满诗意的联盟 2020-08-23
raksmart0 2020-08-17
yfightfors 2020-08-16
84487600 2020-08-16
qdqht00 2020-07-26
WebVincent 2020-07-21
hzyuhz 2020-07-04
fengchao000 2020-07-04
javaraylu 2020-06-28
baijinswpu 2020-06-28
ZHANGRENXIANG00 2020-06-28
Teamomc 2020-06-28
Catastrophe 2020-06-26
hell0kitty 2020-06-17
我欲疾风前行 2020-06-18