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

简单的爬虫架构

相关推荐
张较瘦_3 分钟前
JavaScript | 数组方法实战教程:push()、forEach()、filter()、sort()
开发语言·javascript·ecmascript
Filotimo_17 分钟前
EntityGraph的概念
java·开发语言·数据库·oracle
wregjru18 分钟前
【读书笔记】Effective C++ 条款1~2 核心编程准则
java·开发语言·c++
lingran__1 小时前
C语言自定义类型详解 (1.1w字版)
c语言·开发语言
tang777891 小时前
Python爬虫代理,选短效IP还是长效IP?
爬虫·python·tcp/ip
村口曹大爷1 小时前
JDK 24 正式发布:性能压轴,为下一代 LTS 铺平道路
java·开发语言
写文章的大米1 小时前
这份数据验证方案,可以让你的 FastAPI 崩溃率直降90%
python
xingzhemengyou11 小时前
Python 有哪些定时器
前端·python
站大爷IP1 小时前
Python自动整理音乐文件:按艺术家和专辑分类歌曲
python
BBB努力学习程序设计2 小时前
Python 高效处理大数据:生成器(Generator)的工作机制与实战技巧
python