我正在尝试返回视频的持续时间,但遇到了麻烦。
#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
但我不知道如何从中获得价值。有什么建议吗?