pythonrsspython-3.7feedparser

Issue while using python rss feed with feedparser


I am trying to get the data from a rss feed using python 3.7.7 and feedparser.

I am able to get the simple information like feed['title'] but I am unable to get feed['ht:approx_traffic'] which is one of the tags that I want.

import feedparser

def getFeed():
    feed = feedparser.parse('https://trends.google.com/trends/trendingsearches/daily/rss?geo=US')
    for post in feed.entries:  
        print(post['title']) // works
        print(post['ht:approx_traffic']) // error


getFeed()

Solution

  • The key that you're looking for is ht_approx_traffic not ht:approx_traffic.

    You can see the list of keys with

    print(post.keys())