【发布时间】:2012-01-03 02:33:54
【问题描述】:
我正在尝试将 Wordpress XML 转换为 Octopress,部分使用 BeautifulSoup 进行迁移。
当我运行 exitwp 时,我得到以下输出:
writing......................................................Traceback (most recent call last):
File "exitwp.py", line 293, in <module>
write_jekyll(data, target_format)
File "exitwp.py", line 284, in write_jekyll
out.write(html2fmt(i['body'], target_format))
File "exitwp.py", line 45, in html2fmt
return html2text(html, '')
File "/Users/kevinquillen/Documents/workspace/exitwp2/html2text.py", line 700, in html2text
return optwrap(html2text_file(html, None, baseurl))
File "/Users/kevinquillen/Documents/workspace/exitwp2/html2text.py", line 695, in html2text_file
h.feed(html)
File "/Users/kevinquillen/Documents/workspace/exitwp2/html2text.py", line 285, in feed
HTMLParser.HTMLParser.feed(self, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 108, in feed
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 148, in goahead
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 229, in parse_starttag
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 304, in check_for_whole_start_tag
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 115, in error
HTMLParser.HTMLParseError: malformed start tag, at line 1, column 64
我尝试使用 BeautifulSoup 3.2.0 和 3.0.7a,但运气不佳。
我还尝试在帖子上导出不同的日期范围,但在第 1 行仍然出现相同的错误,但列号发生了变化。
我唯一能想到的是一些较旧的帖子中有 AdSense 代码,但除此之外,我怎样才能轻松地找出它在帖子内容上的阻塞位置?
OSX 10.7 上的 Python 2.7 版
编辑:也发生在没有错误标记的页面转储(只有 2 页)上。
更新:它似乎不喜欢锚标签。如下所示的标记,内容中非常基本的链接。删除它们,它编译正确。为什么它不喜欢这个 HTML?删除它们会导致它编译没有错误。
<a href="http://www.google.com" target="_blank">Google</a>
【问题讨论】:
-
你能添加一些xml不适合你的例子吗?
标签: python beautifulsoup