网页分析

网页分析工具beautifulsoup学习

…衆ロ難τιáo~ 提交于 2019-11-27 21:02:22
Beautiful Soup是一个用来解析HTML和XML的python库,它可以按照你喜欢的方式去解析文件,查找并修改解析树。它可以很好的处理不规范标记并生成剖析 树(parse tree). 它提供简单又常用的导航(navigating),搜索以及修改剖析树的操作。 安装 beautifulsoup #安装版本3 apt-get install python-beautifulsoup #安装版本4 apt-get install python-bs4 python-bs4-doc 既然是练习,就使用文档上的例子进行练习,文档的HTML采用以下内容: <html><head><title>The Dormouse's story</title></head> <p class="title"><b>The Dormouse's story</b></p> <p class="story">Once upon a time there were three little sisters; and their names were <a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>, <a href="http://example.com/lacie" class="sister" id=