Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26266970
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: Python/Ruby

2010-04-11 16:12:43

解析一个页面的时候遇到了这个异常。一GOOGLE发现说是这个页面存在不标准的HTML代码。
一检查我的页面:
iv style="margin-top: 3px;">
果然!
还有
43e
 width=15 height=19 style="display: inline;">

看来不同的页面犯这种错误的还不一样。有点昏了!
应当如何替换呢?

查看了一下其官网的说法:可以有如下的解决方案:
1. Pre-process the data so that HTMLParser can handle it.
2. Use lxml or html5lib.
3. Use Beautiful Soup 3.0.7a, the last version that uses SGMLParser.

我试一下用第三种看看!
没用效果的还是报一样的错误!


阅读(1180) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

hkebao2010-04-19 17:42:45

labels = '[' + ','.join(['"'+x.replace('"', r'\"')+'"' for x in labels_list]) + ']'

hkebao2010-04-19 17:25:19

常用的beautiful soup代码示例 tmpstr = "".join([str(s) for s in subjectCSS])