从0开始学爬虫9之requests库的学习之环境搭建

时间:2024-04-23 10:34:06

从0开始学爬虫9之requests库的学习之环境搭建

Requests库的环境搭建

环境:python2.7.9版本

参考文档:http://2.python-requests.org/zh_CN/latest/

httpbin.org可以模拟http服务器,速度较慢,可以按照插件模拟http服务器

pip install gunicorn httpbin

gunnicorn不支持windows需要在linux系统中安装

启动http服务

[root@localhost ~]# gunicorn httpbin:app

[2019-07-17 22:08:50 +0000] [46575] [INFO] Starting gunicorn 19.9.0

[2019-07-17 22:08:50 +0000] [46575] [INFO] Listening at: http://127.0.0.1:8000 (46575)

[2019-07-17 22:08:50 +0000] [46575] [INFO] Using worker: sync

[2019-07-17 22:08:50 +0000] [46580] [INFO] Booting worker with pid: 46580

# 修改监听地址

[root@localhost ~]# gunicorn httpbin:app -b 0.0.0.0:8080

Requests是keep-alive可以重复利用一个连接

从0开始学爬虫9之requests库的学习之环境搭建