import elementtree.ElementTree as ET
import urllib  

name = name.lower().replace(' ','%20')
id_search = 'http://services.tvrage.com/myfeeds/search.php?key=ag6txjP0RH4m0c8sZk2j&show='+name
tree = ET.parse(urllib.urlopen(id_search))
root = tree.getroot()
showid = root.find('showid')
url = 'http://services.tvrage.com/myfeeds/episode_list.php?key=ag6txjP0RH4m0c8sZk2j&sid='+str(showid)

For some reason the showid comes up as none. Any help on this would be great. I'm using this on xbmc addon to scrape the showid.

Here is the link http://services.tvrage.com/myfeeds/search.php?key=ag6txjP0RH4m0c8sZk2j&show=black%20sails

有帮助吗?

解决方案

The root-element of the xml-file is the results-element, only containing show-elements. You're trying to take subelement show-id from results, while show-id-elements are all subelements of show.

You could use showid = root.find('show/show-id'), but probably you want toe use a for-loop and the findall-function instead of the find-function.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top