How do I parse youtube xml for a specific entry?
Posted
by
sharataka
on Stack Overflow
See other posts from Stack Overflow
or by sharataka
Published on 2012-11-10T04:25:22Z
Indexed on
2012/11/10
4:59 UTC
Read the original article
Hit count: 153
I am trying to return the duration of the video but am having trouble.
#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
When I print item, I see as the last element:
Element '{http://gdata.youtube.com/schemas/2007}duration' at 0x10c4fb7d0
But I don't know how to get the value from this. Any advice?
© Stack Overflow or respective owner