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

简单的爬虫架构

相关推荐
u***32432 小时前
使用python进行PostgreSQL 数据库连接
数据库·python·postgresql
青瓷程序设计5 小时前
动物识别系统【最新版】Python+TensorFlow+Vue3+Django+人工智能+深度学习+卷积神经网络算法
人工智能·python·深度学习
tobebetter95275 小时前
How to manage python versions on windows
开发语言·windows·python
F_D_Z5 小时前
数据集相关类代码回顾理解 | sns.distplot\%matplotlib inline\sns.scatterplot
python·深度学习·matplotlib
9***P3346 小时前
PHP代码覆盖率
开发语言·php·代码覆盖率
daidaidaiyu6 小时前
一文入门 LangGraph 开发
python·ai
CoderYanger6 小时前
优选算法-栈:67.基本计算器Ⅱ
java·开发语言·算法·leetcode·职场和发展·1024程序员节
jllllyuz6 小时前
Matlab实现基于Matrix Pencil算法实现声源信号角度和时间估计
开发语言·算法·matlab
多多*6 小时前
Java复习 操作系统原理 计算机网络相关 2025年11月23日
java·开发语言·网络·算法·spring·microsoft·maven
p***43487 小时前
Rust网络编程模型
开发语言·网络·rust