百度 Google Bing
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Requests 库安装

Posted on 2019-05-08 11:57  都说是捡便宜了  阅读(178)  评论(0编辑  收藏  举报

 pip3 install --user requests  使用pip3 安装request库;

 

打开IDLE,键入 import requests ,

r = requests.get("http://www.baidu.com")
r.status_code
r.encoding = 'utf-8'
print(r.text)

 

 

 r.encoding   #获取http协议header中的charset , r.apparent_encoding #通过解析文件内容得出字符类型 ;通常情况下使用 r.encoding = r.apparent_encoding