例如,有什么方法可以计算有多少人发给我的Twitter微博,其中包含特定的#标签,并且按用户细分了吗?
等。
答案 0 :(得分:2)
您可以将搜索API(https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html)与带有@you #certainhashtag
的q参数一起使用。
所以在这里,您有一条推文提及您并包含您的主题标签。
您可以将它们写入CSV文件。要执行计数,在Linux系统上,您可以通过以下几个命令来实现计数:awk,cut,grep,wc,uniq ...
或者在获取推文时,可以编写如下过滤器:
答案 1 :(得分:0)
您可以使用counts endpoint使用高级搜索API来执行此操作。 30天和完整档案搜索API均支持付费高级级别的计数(免费沙箱中不提供)。
您将进行与此查询类似的查询,以获取时间序列的计数数据。
{
"query": "to:andypiper from:userA #certainhashtag",
"bucket": "day"
}
结果看起来像这样(对于30天的搜索请求):
{
"results": [
{
"timePeriod": "201809040000",
"count": 2
},
{
"timePeriod": "201809030000",
"count": 0
},
{
"timePeriod": "201809020000",
"count": 0
},
{
"timePeriod": "201809010000",
"count": 0
},
{
"timePeriod": "201808310000",
"count": 0
},
{
"timePeriod": "201808300000",
"count": 0
},
{
"timePeriod": "201808290000",
"count": 0
},
{
"timePeriod": "201808280000",
"count": 0
},
{
"timePeriod": "201808270000",
"count": 0
},
{
"timePeriod": "201808260000",
"count": 0
},
{
"timePeriod": "201808250000",
"count": 0
},
{
"timePeriod": "201808240000",
"count": 0
},
{
"timePeriod": "201808230000",
"count": 0
},
{
"timePeriod": "201808220000",
"count": 0
},
{
"timePeriod": "201808210000",
"count": 0
},
{
"timePeriod": "201808200000",
"count": 0
},
{
"timePeriod": "201808190000",
"count": 0
},
{
"timePeriod": "201808180000",
"count": 0
},
{
"timePeriod": "201808170000",
"count": 0
},
{
"timePeriod": "201808160000",
"count": 0
},
{
"timePeriod": "201808150000",
"count": 0
},
{
"timePeriod": "201808140000",
"count": 0
},
{
"timePeriod": "201808130000",
"count": 0
},
{
"timePeriod": "201808120000",
"count": 0
},
{
"timePeriod": "201808110000",
"count": 0
},
{
"timePeriod": "201808100000",
"count": 0
},
{
"timePeriod": "201808090000",
"count": 0
},
{
"timePeriod": "201808080000",
"count": 0
},
{
"timePeriod": "201808070000",
"count": 0
},
{
"timePeriod": "201808060000",
"count": 0
},
{
"timePeriod": "201808050000",
"count": 0
}
],
"totalCount": 2,
"requestParameters": {
"bucket": "day",
"fromDate": "201808050000",
"toDate": "201809041241"
}
}
然后,您只需要计算总数即可。