在rss阅读器中显示我网站中某些文章的正文时,它们是全宽的。我希望在rss feed中使用时为所有图像添加一个width属性,最好使用过滤器,因为我使用模板将主体排列在其他元素中。
我写了以下方法作为测试:
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)
所以也许我的方法完全错了,希望有人可以帮助我。