Im uses a parser to get rss objects. When i started
live_leak.links
I get
[{'type': 'text/html', 'rel': 'alternate', 'href':
'http://www.liveleak.com/view?i=abf_1476121939'},
{'type': 'application/x-shockwave-flash', 'rel': 'enclosure', 'href':
'http://www.liveleak.com/e/abf_1476121939'}]
But when I try this one
live_leak.links[1]
I get an index index out of range, remember that you worked before, and suddenly it didn’t work. I had this in my code, and it took me several hours to find, because I did not understand that this was not working. If no one knows that I will do the string replacement as a hack, but I will rather do what already works.
it also works
live_leak[0]
he returns
[{'type': 'text/html', 'rel': 'alternate', 'href':
'http://www.liveleak.com/view?i=abf_1476121939'}]
which is strange because the other will not work
EDIT
def pan_task():
url = 'http://www.liveleak.com/rss?featured=1'
name = 'live leak'
live_leaks = [i for i in feedparser.parse(url).entries]
the_count = len(live_leaks)
ky = feedparser.parse(url).keys()
oky = [i.keys() for i in feedparser.parse(url).entries][:12]
try:
live_entries = [{
'html': live_leak.links,
'href': live_leak.links[0]['href'],
'src': live_leak.media_thumbnail[0]['url'],
'text': live_leak.title,
'comments': live_leak.description,
'url': live_leak.links[0]['href'],
'embed': live_leak.links[1]['href'],
'text': live_leak.title,
'comments': live_leak.description,
'name': name,
'url': live_leak.link,
'author': None,
'video': False
} for live_leak in live_leaks]
except IndexError:
print('error check logs')
live_entries = []
return print(live_entries[0])
losee source
share