在将python rss feed与feedparser结合使用时出现问题

问题描述 投票:0回答:1

我正在尝试使用python 3.7.7和feedparser从rss提要中获取数据。

我能够获得简单的信息,例如feed ['title'],但我无法获得feed ['ht:approx_traffic'],这是我想要的标签之一。

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()
python rss python-3.7 feedparser
1个回答
0
投票

您要查找的键是ht_approx_traffic而不是ht:approx_traffic

您可以通过以下方式查看键列表

print(post.keys())
© www.soinside.com 2019 - 2024. All rights reserved.