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

简单的爬虫架构

相关推荐
孙启超5 分钟前
【AI开发之Rust】第 22 课:一键多平台与工程收尾 —— CI、发布检查与结课
开发语言·后端·rust
happylifetree8 小时前
Python09:核心语法-数据存储与运算-字面量
python
落魄实习生8 小时前
Agent Scope Java 2.x 系列【7】工具使用
java·开发语言·ai
心之语歌8 小时前
Tkinter 画布基本梳理
运维·服务器·python
茉莉玫瑰花茶8 小时前
GO [ 方法 ]
开发语言·后端·golang
Wx-bishekaifayuan8 小时前
django个性化旅游路线推荐平台49005-计算机课程设计、毕业设计
spring boot·后端·python·django·课程设计·express·旅游
狗凯之家源码网9 小时前
微博图床 PHP 系统搭建与实战应用指南
android·开发语言·php
小白快快跑哦9 小时前
python-字符串全解(六):正则表达式-量词
python·正则表达式·字符串
禹凕9 小时前
机器学习之Selenium(Machina Learning about Selenium)
爬虫·python·selenium·测试工具·机器学习
乌暮10 小时前
深入理解 Java 泛型:把「万能盒子」用对、用稳
java·开发语言·后端·学习