def get_in_theaters():
#stream=urlopen('http://www.videodetective.com/api/intheaters.aspx?DeveloperId={KEY}')
#stream=urlopen('http://semprog.com/data/intheaters.xml')
stream=file('intheaters.xml')
root=parse(stream)
stream.close()
movies=[]
for item in root.getElementsByTagName('item'):
movie={}
# Get the ID, title, and director
movie['id']=getdata(item,'PublishedId')
movie['title']=getdata(item,'Title')
movie['director']={'id':getdata(item,'DirectorID'),'name':getdata(item,'Director')}
# Actor tags are numbered: Actor1, Actor2, etc.
movie['actors']=[]
for i in range(1,6):
actor=getdata(item,'Actor%d' % i)
actorid=getdata(item,'ActorId%d' % i)
if actor!=None and actorid!=None:
movie['actors'].append({'name':actor,'id':actorid})
movies.append(movie)
return movies
# Generate an RDF Graph from the Movie Data
评论列表
文章目录