python学习笔记——安装beautifulsoup

python2.7 win10

beautifulsoup是一个可用于爬虫项目的框架,可对html等文件进行解析,并且提供了一些列的函数高效便捷的读取和匹配内容。

安装方式:

1、安装包形式

先确认python有无安装pip脚本:

python学习笔记——安装beautifulsoup

python学习笔记——安装beautifulsoup

通常环境变量配置好,使用install安装的python都是正常的。

然后下载beautifulsoup:https://pypi.python.org/pypi/beautifulsoup4:

python学习笔记——安装beautifulsoup

使用pip命令安装beautifulsoup:

python学习笔记——安装beautifulsoup

导入即可使用:

python学习笔记——安装beautifulsoup

如果解析html的时候出现如下异常,说明没有所需的解析器,这个bs解析html使用的是lxml解析器。

ValueError: Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library?

我们使用python自带的easyinstall 就可以在线安装:

python学习笔记——安装beautifulsoup