python 爬虫的开发环境配置

1、新建一个python项目

2、在控制台中分别安装下面三个包

pip install requests

pip install beautifulsoup4

pip install selenium/

如果安装时报以下错误:

raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError:

HTTPSConnectionPool(host='files.pythonhosted.org', port=443):
Read timed out.

可以多试几次,或者运行以下命令,延长超时时间

1000 是超时时间

pip --default-timeout=1000 install -U selenium

我在安装 selenium 时以上方法都不行,最后百度了一下,运行以下命令一下子就可以了!

pip --default-timeout=100 install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple

3、检查是否安装完成

在项目下建一个 test 包。之后在 test 包下新建一个 test_env.py 文件,写入如下代码然后运行,如果没有报错,则证明上述三个包安装成功

python 复制代码
import requests
from bs4 import BeautifulSoup
import selenium

print('ok')

简单的爬虫架构

相关推荐
FRing034 分钟前
for循环、while循环、Java高级语法、数组
java·开发语言·后端·算法
syf0611137 分钟前
Java Math 类详解:常用数学运算方法全解析
java·开发语言
是main不是漫35 分钟前
【双指针 | LeetCode11 盛最多水的容器】O(n²) 超时,O(n) 封神:这道“装水题“只差一个思路
开发语言·数据结构·c++·算法
钱栈up2 小时前
GitHub热榜实测|Sherlock:一个用户名搜遍全网
python·开源·github
geovindu2 小时前
python: Gradient Boosting
开发语言·后端·python·算法·boosting
Agent世界2 小时前
发布台账字段漂移:1265 条记录里 190 条没有标题
python·自动化运维
星夜离尘563 小时前
MATLAB:两路读数平均相差 8 mV,换位能分出传感器偏差和通道偏差吗?
开发语言·matlab
时间的情敌3 小时前
Three.js 水位模拟、水体 Shader、罐体液位动态变化(水箱、水池、储罐液位)
开发语言·javascript·three.js
NendoZen3 小时前
Bubble Tea V2构建Go TUI应用教程
开发语言·golang·xcode