HTMLParser错误解决
来源:互联网 发布:淘宝的体检中心在哪里 编辑:程序博客网 时间:2024/06/05 05:30
费劲巴拉写了一个爬虫程序,总算运行顺利了,结果有出现了一个HTMLParser错误,
提示信息如下:
HTMLParser.HTMLParseError: malformed start tag
提示内容大概是说,这个不是BS的bug,如果需要解决,需要使用一个新的网页解析器lxml或者html5lib.
好吧,安装html5lib或者lxml。
lxml: lxml由于GCC版本的问题一直显示安装失败.
html5lib安装成功后,import时候又出现错误:
>>> import html5lib
Traceback (most recent call last):
File "<stdin>",line 1, in <module>
File"/usr/local/lib/python2.6/dist-packages/html5lib/__init__.py", line16, in <module>
from .html5parserimport HTMLParser, parse, parseFragment
File"/usr/local/lib/python2.6/dist-packages/html5lib/html5parser.py",line 9, in <module>
from ordereddictimport OrderedDict
ImportError: No module named ordereddict
网上查了一下,需要再安装一个ordereddicthttp://www.cnblogs.com/xiami303/archive/2012/08/28/2660657.html
作者说:后来我知道,其实可以easy_install安装OrderedDict的package
加上:import html5lib
原:soup = BeautifulSoup(html,'html.parser')
现:soup = BeautifulSoup(html,'html5lib')
再试一下出问题的网页,成功了~~~
撒花,感谢~~~~~~~~~~~~~~~~~~~~
- HTMLParser错误解决
- HtmlParser 错误解决 character mismatch (new: [] != old: []) for encoding change from ...
- HTMLParser
- HTMLParser
- htmlparser
- htmlparser
- htmlparser
- HTMLParser
- HTMLParser
- htmlparser
- HTMLParser
- HTMLParser
- htmlparser
- htmlparser
- HTMLParser
- HTMLParser
- iOS中 libxml/HTMLparser.h file not found 错误
- 关于扩展HTMLParser,解决自定义tag的问题
- MFC CAsyncSocket
- Spring整理系列(11)——@Configuration注解、@Bean注解以及配置自动扫描、bean作用域 发表于2016/8/11 15:16:16 10628人阅读 分类: Spring
- 选择
- Spring Boot -- Swagger之接口分组
- [知了堂学习笔记]_记一次BootStrap的使用
- HTMLParser错误解决
- JMX 入门例子
- python datetime 加密 笔记
- 欢迎使用CSDN-markdown编辑器
- The version of CocoaPods used to generate the lockfile (1.2.1) is higher than the version of the cur
- Maven私服Nexus3.x环境构建操作记录
- web 多行文字超出显示省略号
- django时间的时区问题
- 实验吧 web题--代码审计类