Reputation: 1046
I'm Using Python2.7
and feedparser
. I need to read feed of a wordpress
site. I could read some common feed tags like title, content
, ... of each items from feed, but I couldn't read some custom feed that added
.
The feed url is: http://www.aecinema.ir/feed/.
You can see image tag in each items that is an "Added feed" , but I could't read.
My code:
feed = feedparser.parse("http://www.aecinema.ir/feed/")
for item in feed["items"]:
print item["title"], item["image"]
also i read feed as bellow:
print feed.entries[0].title, feed.entries[0].image
But in each case the error is same.
error: object has no attribute 'image'
What is wrong in code ??? :(
Upvotes: 2
Views: 387
Reputation: 25329
The code is good, but the feed is invalid. See validation results.
<image>
isn't defined in RSS 2.0 specification as an <item>
subelement, so feedparser doesn't handle them.
Upvotes: 1
Reputation: 207
The reason is that in your feeds.entries[0] FeedParserDict the key for "image" does not exist. If you run
feed.entries[0].keys()
It will output the keys that are available. It does not include any key "image".
Upvotes: 1