【发布时间】:2012-11-10 04:25:22
【问题描述】:
我正在尝试返回视频的时长,但遇到了问题。
#YOUTUBE FEED
#download the file:
file = urllib2.urlopen('http://gdata.youtube.com/feeds/api/videos/2s0vk2wEMtA')
#convert to string:
data = file.read()
#close file because we dont need it anymore:
file.close()
#entire feed
root = etree.fromstring(data)
for entry in root:
for item in entry:
print item
当我打印项目时,我看到的是最后一个元素:
Element '{http://gdata.youtube.com/schemas/2007}duration' at 0x10c4fb7d0
但我不知道如何从中获得价值。有什么建议吗?
【问题讨论】:
标签: python xml parsing youtube