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')

简单的爬虫架构

相关推荐
站大爷IP17 小时前
Java调用Python的5种实用方案:从简单到进阶的全场景解析
python
用户8356290780511 天前
从手动编辑到代码生成:Python 助你高效创建 Word 文档
后端·python
侃侃_天下1 天前
最终的信号类
开发语言·c++·算法
c8i1 天前
python中类的基本结构、特殊属性于MRO理解
python
echoarts1 天前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
liwulin05061 天前
【ESP32-CAM】HELLO WORLD
python
Aomnitrix1 天前
知识管理新范式——cpolar+Wiki.js打造企业级分布式知识库
开发语言·javascript·分布式
Doris_20231 天前
Python条件判断语句 if、elif 、else
前端·后端·python
Doris_20231 天前
Python 模式匹配match case
前端·后端·python
每天回答3个问题1 天前
UE5C++编译遇到MSB3073
开发语言·c++·ue5