我正在尝试在Django中使用Beautiful Soup来提取XML标签。以下是我要使用的标签示例:
<item>
<title>
Title goes here
</title>
<link>
Link1 goes here
</link>
<description>
Description goes here
</description>
<media:thumbnail url="Image URL goes here" height="222" width="300"/>
<pubDate>Thu, 15 Sep 2016 13:24:48 EDT</pubDate>
<guid isPermaLink="true">
Link2 goes here
</guid>
</item>
我已经获取了标题、链接和描述标签的字符串。但是我在获取media:thumbnail
标签中的URL时遇到了问题。
以下是我获取其余标签值的代码片段:
soup=BeautifulSoup(urlopen(xmllink),'xml')
for items in soup.find_all('item'):
listTitle.append(items.title.get_text())
listURL.append(items.link.get_text())
listDescription.append(items.description.get_text())
帮助