【问题标题】:Retrieving JSON Title, URL from Pygooglenews feedParser从 Pygooglenews feedParser 检索 JSON 标题、URL
【发布时间】:2021-03-25 21:45:08
【问题描述】:

我正在尝试从 pyGoogleNews (https://github.com/kotartemiy/pygooglenews) 中检索值 即使用 feedParser 输出值。

代码片段如下:

from pygooglenews import GoogleNews

gn = GoogleNews(lang = 'en', country = 'SG')
cars = gn.topic_headlines('CAAqJAgKIh5DQkFTRUFvSEwyMHZNR3MwYWhJRlpXNHRSMElvQUFQAQ')
print(cars)

返回以下内容:(似乎不是有效的 JSON 文件)

我想要实现的是循环“条目”列表,以获取相关标题和链接。

我该怎么做?

【问题讨论】:

    标签: python feedparser google-news pygooglenews


    【解决方案1】:

    解决方法如下:

    for item in cars['entries']:
        print(item['title'])
        print(item['link'])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-10
      • 2016-06-04
      • 1970-01-01
      • 2020-03-13
      • 1970-01-01
      • 2015-02-06
      • 1970-01-01
      • 2013-11-24
      相关资源
      最近更新 更多