OK I finally got a channel to work. YEAH!!!
But I cannot get to into the description element to get the icon and description for each episode that you suggested in the post below:
You have to do this in 2 steps:
- Get the value of the description element:
xml = XML.ElementFromURL()
Some more code here to loop over all the items
…
Get the description string
description = xml.xpath(‘//description’)
- Then treat the description string as a piece of HTML and use another xpath query to get the data you want:
html = HTML.ElementFromString(description)
image = html.xpath(‘//img/@src’)[0]
I tried this coding you suggested above and I still get errors. I even pulled all the data that is available in one of the description fields and created an html document with html and body tags around it and used xpath checker to see what the xpath commands would pull from the data in the description line. First, the text is on nine different lines, so I am not sure how I can pull out the description. Secondly and more importantly, to pull image address, the command you gave above showed as the the proper format in xpath checker, but when I try to put that line in my code, I get an error. "IndexError: list index out of range."
An example of one of the RSS feed pages I am trying to pull up is:
http://www.lstudio.com/rss/lstudiorss-3-minute-talk-show-with-barry-sobel.xml
The data in one of the description fields is :
<
Barry Sobel, Fred Willard, Stephen Moyer
Featuring host Barry Sobel and co-host Fred Willard, actor Stephen Moyer of ''True Blood,'' and a musical performance by Geoffro.
]]>
So I included the code you showed above except since these are coming from a item parent in an xml document I used ./description instead of //description. Here is my code:
xml = XML.ElementFromURL(SHOW_RSS)
for video in xml.xpath('//item'):
epUrl = video.xpath(‘./link//text()’)[0]
epTitle = video.xpath(‘./title//text()’)[0]
epDate = video.xpath(‘./pubDate//text()’)[0]
epDate = Datetime.ParseDate(epDate)
description = video.xpath(‘./description’)[0]
html = HTML.ElementFromString(description)
#epSummary = html.xpath(‘//text()’)[0]
epThumb = html.xpath(‘//img//@src’)[0]
I get the error on this last line, where I am trying to pull the thumb. (I just stopped the summary line from running for now with the comment code, since it returns nine lines of data and I need line 8.)