python3添加requests库

1、资源下载

https://codeload.github.com/psf/requests/zip/master

https://www.python.org/

https://files.pythonhosted.org/packages/41/b6/4f0cefba47656583217acd6cd797bc2db1fede0d53090fdc28ad2c8e0716/certifi-2018.10.15.tar.gz

https://files.pythonhosted.org/packages/a5/74/05ffd00b4b5c08306939c485869f5dc40cbc27357195b0a98b18e4c48893/urllib3-1.24.tar.gz

https://files.pythonhosted.org/packages/65/c4/80f97e9c9628f3cac9b98bfca0402ede54e0563b56482e3e6e45c43c4935/idna-2.7.tar.gz

https://files.pythonhosted.org/packages/fc/bb/a5768c230f9ddb03acc9ef3f0d4a3cf93462473795d18e9535498c8f929d/chardet-3.0.4.tar.gz

2、说明

系统:
CentOS Linux release 7.4.1708

系统已经安装了python3替代了自带的python2

使用应用requests库的账户登录系统

3、编译安装

安装依赖库

tar -zxf certifi-2018.10.15.tar.gz
cd certifi-2018.10.15/
python setup.py install
tar -zxf urllib3-1.24.tar.gz
cd urllib3-1.24/
python setup.py install
tar -zxf idna-2.7.tar.gz
cd idna-2.7/
python setup.py install
tar -zxf chardet-3.0.4.tar.gz
cd chardet-3.0.4/
python setup.py install

安装requests库

unzip requests-master.zip
cd requests-master/
python setup.py install

查看库

$ pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
certifi (2018.10.15)
chardet (3.0.4)
idna (2.7)
pip (9.0.1)
psycopg2-binary (2.8.3)
requests (2.22.0)
setuptools (28.8.0)
tornado (6.0.2)
urllib3 (1.24)

原文地址:https://www.cnblogs.com/xiaoxiaozhou/p/11316869.html

时间: 2024-08-30 02:24:06

python3添加requests库的相关文章

Python3网络爬虫——三、Requests库的基本使用

一.什么是Requests Requests是用Python语言编写,基于urllib,采用Apache2 Licensed开元协议的HTTP库.它比urllib更加的方便,可以节约我们大量的工作完全满足HTTP测试需求.简单来讲,即Python实现的简单易用的HTTP库. 二.Requests库的安装 如果是初学者,建议使用原生Python3进行安装. 1 >> pip3 install requests 如果有一定的Python基础(会基本语法即可),使用anaconda进行安装更加方便,

requests库详解 --Python3

本文介绍了requests库的基本使用,希望对大家有所帮助. requests库官方文档:https://2.python-requests.org/en/master/ 一.请求: 1.GET请求 coding:utf8 import requests response = requests.get('http://www.httpbin.org/get') print(response.text) 2.POST请求 # coding:utf8 import requests data = {

python3 requests库文件上传与下载

在接口测试学习过程中,遇到了利用requests库进行文件下载和上传的问题.同样,在真正的测试过程中,我们不可避免的会遇到上传和下载的测试. 文件上传: url = ztx.host+'upload/uploadFile?CSRFToken='+self.getCSRFToken()#上传文件的接口地址 header = { 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko', '

Python urllib库和requests库

1. Python3 使用urllib库请求网络 1.1 基于urllib库的GET请求 请求百度首页www.baidu.com ,不添加请求头信息: 1 import urllib.requests 2 3 4 def get_page(): 5 url = 'http://www.baidu.com/' 6 res = urllib.request.urlopen(url=url) 7 page_source = res.read().decode('utf-8') 8 print(page

python爬虫之requests库

requests库介绍 发送http请求的第三方库,兼容python2和python3 安装: pip install requests 使用: import requests发送请求response = requests.get(url)response = requests.post(url) 响应内容请求返回的值是一个response对象,是对http协议服务端返回数据的封装response对象主要属性和方法: response.status_code  返回码  response.hea

python爬虫从入门到放弃(四)之 Requests库的基本使用

什么是Requests Requests是用python语言基于urllib编写的,采用的是Apache2 Licensed开源协议的HTTP库如果你看过上篇文章关于urllib库的使用,你会发现,其实urllib还是非常不方便的,而Requests它会比urllib更加方便,可以节约我们大量的工作.(用了requests之后,你基本都不愿意用urllib了)一句话,requests是python实现的最简单易用的HTTP库,建议爬虫使用requests库. 默认安装好python之后,是没有安

OpenCV 3.0.0-beta 编译支持Python3的链接库

官方编译的OpenCV中只带了Python2的链接库,Python3的链接库需要自己特别编译,官方编译版下载地址:http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0-beta/ 1. 解压opencv-3.0.0-beta.exe到D:/,安装cmake-2.8.12.2-win32-x86.exe,安装Python3.4(32位)且Python 需要安装 numpy 2. CMake设置: 1) cmake选

python爬虫---requests库的用法

requests是python实现的简单易用的HTTP库,使用起来比urllib简洁很多 因为是第三方库,所以使用前需要cmd安装 pip install requests 安装完成后import一下,正常则说明可以开始使用了. 基本用法: requests.get()用于请求目标网站,类型是一个HTTPresponse类型 import requests response = requests.get('http://www.baidu.com')print(response.status_c

python requests库学习笔记(下)

1.请求异常处理 请求异常类型: 请求超时处理(timeout): 实现代码: import requestsfrom requests import exceptions        #引入exceptions A:请求超时 def timeout_request():    try:        response = requests.get(build_uri('user/emails'), timeout=0.1)    except exceptions.Timeout as e: