我可以阅读标签,除非有前缀。我没有运气搜索上一个问题。
我需要阅读media:content
。我试过了image = node.find("media:content")
。RSS输入:
<channel>
<title>Popular Photography in the last 1 week</title>
<item>
<title>foo</title>
<media:category label="Miscellaneous">photography/misc</media:category>
<media:content url="http://foo.com/1.jpg" height="375" width="500" medium="image"/>
</item>
<item> ... </item>
</channel>
我可以阅读兄弟标签title
。
from xml.etree import ElementTree
with open('cache1.rss', 'rt') as f:
tree = ElementTree.parse(f)
for node in tree.findall('.//channel/item'):
title = node.find("title").text
我一直在使用文档,但仍停留在“前缀”部分。