【发布时间】:2012-03-10 01:08:39
【问题描述】:
当在 rss 阅读器中显示我网站中某些文章的正文时,它们是全角的。我希望在 rss 提要中使用时为所有图像添加宽度属性,最好使用过滤器,因为我使用模板将正文排列在其他一些元素中。
我写了以下方法,作为测试:
try:
_parser = minidom.Text()
_parser.data = obj.body
_xml = _parser.toxml(encoding='UTF-8')
_return = minidom.parseString(_xml)
_images = _return.getElementsByTagName('img')
print "============= This is what I found: ============="
#print _images
except ExpatError as (e):
print "============= This is what I found: ============="
print ErrorString(e.code)
但输出看起来像这样:
============= This is what I found: =============
syntax error
============= This is what I found: =============
not well-formed (invalid token)
============= This is what I found: =============
syntax error
============= This is what I found: =============
syntax error
============= This is what I found: =============
syntax error
============= This is what I found: =============
syntax error
(and so on, there are no working cases)
所以也许我的方法完全错误,希望有人能帮助我。
【问题讨论】: