【发布时间】:2017-03-06 17:35:46
【问题描述】:
我正在尝试在 python 中获取不同德国城市的主题标签。所以首先我得到了可用的趋势:
twitter.trends.available(_woeid=23424829)
然后从中我得到每个地方的趋势:
for trend in germany_trends:
twitter.trends.place(_id=trend['woeid'])[0]['trends']
之后,我过滤结果以必须在每个城市中使用最高 tweet_volume 发布推文。问题是:每个城市都有相同的标签。我从“可用趋势”中得到了 10 个不同的城市,但主题标签 90% 相同。
当我查看像 https://www.trendsmap.com/ 这样的地图时,我想知道我做错了什么。他们在所有这些城市都有许多单独的主题标签。
一个示例响应,您可以在其中看到我的意思,主题标签几乎相同,“最佳”主题标签也相同:
"DE, Stuttgart": [
{
"url": "http://twitter.com/search?q=%23ISIS",
"query": "%23ISIS",
"tweet_volume": 21646,
"name": "#ISIS",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=%22Hans+Rosling%22",
"query": "%22Hans+Rosling%22",
"tweet_volume": 44855,
"name": "Hans Rosling",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=%22Betsy+DeVos%22",
"query": "%22Betsy+DeVos%22",
"tweet_volume": 664741,
"name": "Betsy DeVos",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=Nioh",
"query": "Nioh",
"tweet_volume": 24160,
"name": "Nioh",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=%23FCBWOB",
"query": "%23FCBWOB",
"tweet_volume": 14216,
"name": "#FCBWOB",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=%23sid2017",
"query": "%23sid2017",
"tweet_volume": 28277,
"name": "#sid2017",
"promoted_content": null
}
],
"DE, Dresden": [
{
"url": "http://twitter.com/search?q=%22Hans+Rosling%22",
"query": "%22Hans+Rosling%22",
"tweet_volume": 44855,
"name": "Hans Rosling",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=%22Betsy+DeVos%22",
"query": "%22Betsy+DeVos%22",
"tweet_volume": 664741,
"name": "Betsy DeVos",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=Nioh",
"query": "Nioh",
"tweet_volume": 24160,
"name": "Nioh",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=%23FCBWOB",
"query": "%23FCBWOB",
"tweet_volume": 14216,
"name": "#FCBWOB",
"promoted_content": null
},
{
"url": "http://twitter.com/search?q=%23sid2017",
"query": "%23sid2017",
"tweet_volume": 28277,
"name": "#sid2017",
"promoted_content": null
}
],
【问题讨论】:
-
你的问题到底是什么?
-
我在德国的每个城市都获得了相同的“高票”趋势。我想要那个城市特有的趋势。
-
不是因为每个城市都有相同的“高票”趋势吗?
-
我认为 tweet_volume 仅限于一个城市,所以我认为在过滤“高投票”趋势时,我会得到每个城市的最佳趋势......猜猜唯一的方法是比较数组并删除非唯一值
-
没错。可能发生的是
X和Y城市都具有相同的“高投票”趋势。这就是您在城市之间获得重复值的原因。