【beautifulsoup】python标准库解析器解析网页问题解决
来源:互联网 发布:catia软件的应用 编辑:程序博客网 时间:2024/04/29 09:21
使用python标准库解析(即BeautifulSoup(page, "html.parse"))出现网页解析问题
如下,页面明明没有结束,</html>却提前出现了,导致有些text没有了原本与之对应的标签,也就取不到了
在尝试了很多种方法之后,发现是解析器的问题,所以更换了解析器
BeautifulSoup(page, "html5lib")
from bs4 import BeautifulSoupimport urllib.requestimport logginglogging.basicConfig(level=logging.DEBUG)def parse(url): page = urllib.request.urlopen(url) soup = BeautifulSoup(page, "html5lib") _desc_soup = soup.find("div", class_="det-app-data-info") logging.debug("description is %s", _desc_soup.get_text().strip())
使用html5lib解析器需要安装这个model
pip install html5lib
安装之后还是运行会报错,崩溃。。。
module 'html5lib.treebuilders' has no attribute '_base'
其实升级一下html5lib就可以了,升级命令是:
pip install --upgrade html5lib==1.0b8。
现在可以正常运行了~
0 0
- 【beautifulsoup】python标准库解析器解析网页问题解决
- python : BeautifulSoup 网页HTML 解析器
- Python 网页解析器BeautifulSoup示例使用
- 1.6 网页解析器beautifulsoup
- Python爬虫----网页解析器和BeautifulSoup第三方模块
- python使用HTMLParser和BeautifulSoup解析网页
- python网页解析利器——BeautifulSoup
- python : BeautifulSoup 网页 table 解析范例
- Python中使用BeautifulSoup做网页解析
- python使用HTMLParser和BeautifulSoup解析网页
- BeautifulSoup解析网页信息
- beautifulsoup 解析网页内容
- BeautifulSoup解析网页
- 【爬虫】BeautifulSoup解析网页
- 【Python】 html解析BeautifulSoup
- python︱HTML网页解析BeautifulSoup学习笔记
- python 网络爬虫与信息采取之解析网页(一)--BeautifulSoup库
- python解析html之BeautifulSoup
- hdu 4545 魔法串 (模拟)
- tmpl 模板化引擎加载数据 Jquery
- 饼图与柱状图的topN处理
- 关于mybatis扫描所有namespace时报错,最终原因是resultMap不能使用(我的错误记录)
- NSURL学习
- 【beautifulsoup】python标准库解析器解析网页问题解决
- React:创建同时受控与非受控的组件
- LightOJ 1021 Painful Bases 【状压DP+数位DP】
- android studio add fragment from layout
- Maven 手动添加 JAR 包到本地仓库
- 图解HTTPS
- PHPExcel讀取excel數據
- 带有 mask 的 OTSU 自适应阈值
- C++程序crash几种情况