【发布时间】:2019-08-27 21:56:40
【问题描述】:
我有一个来自 Tweepy 的 json 输出,我现在正试图解析它。例如,一些输出是特定区域的趋势标签。由于它是一个大输出,我正在尝试确定如何有效地解析所有主题标签。 json 输出中还有其他信息,例如userid、countrycode 等……但我只对列为name: '#gamenight 的主题标签感兴趣。
# using Tweepy
api.trends_place(2295420)
import json
# Here is a portion of the Tweepy output I received
trends = [{'trends': [{'name': '#RCBvKKR', 'url': 'http://twitter.com/search?q=%23RCBvKKR', 'promoted_content': None, 'query': '%23RCBvKKR', 'tweet_volume': 101508}, {'name': 'created_at': '2019-04-06T00:07:14Z', 'locations': [{'name': 'Bangalore', 'woeid': 2295420}]}]
hashtags = json.dumps(trends)
# Am trying to end up with a way of just extracting 'name' which I believe is how the hashtags are captured
print(hashtags['name'])
【问题讨论】: