“ 介绍Python库BeautifulSoup安装。”
01
—
BeautifulSoup库介绍
Beautiful Soup是Python的一个库,支持Python 2和Python 3,最主要的功能是从网页抓取数据,即爬虫,官网介绍如下:
Beautiful Soup provides a few simple methods and Pythonic idioms for navigating, searching, and modifying a parse tree: a toolkit for dissecting a document and extracting what you need. It doesn't take much code to write an application
Beautiful Soup automatically converts incoming documents to Unicode and outgoing documents to UTF-8. You don't have to think about encodings, unless the document doesn't specify an encoding and Beautiful Soup can't detect one. Then you just have to specify the original encoding.
Beautiful Soup sits on top of popular Python parsers like lxml and html5lib, allowing you to try out different parsing strategies or trade speed for flexibility.
翻译过来就是:
Beautiful Soup提供一些简单易用的方法来处理导航、搜索、修改网页解析树等功能。它是一个工具集合,通过解析文档方便用户提取所需数据,可用很少代码就写出一个完整的程序。
Beautiful Soup自动将输入文档转换为Unicode,输出文档转换为UTF-8,从而使用户不需要考虑文档的编码方式,除非文档没有指定编码,此时则需用户说明文档编码方式。
Beautiful Soup已成为和lxml、html5lib等相当的Python解释器,丰富了用户的解析策略和开发的灵活性。.
Beautiful Soup官网为:https://www.crummy.com/software/BeautifulSoup/
02
—
下载安装
安装方法如下:
到Beautiful Soup官网下载Beautiful Soup库,目前版本为4.6.0。
解压缩,假设放到C:/python36/下。
运行cmd,切换到Beautiful Soup目录下。
运行命令:
setup.py build
setup.py install
在IDE下from bs4 import BeautifulSoup,没有报错说明安装成功。
02
—
PIP安装
如果上一种方法安装不成功,可以用第二种方法,记住,Python3.6下是pip3。
安装方法如下:
pip3 install beautifulsoup4。
在IDE下from bs4 import BeautifulSoup,没有报错说明安装成功。
扫我关注,及时获取技术分享。