如果没有API允许通过特定名称进行请求,我该如何执行此过程任何想法
那里运气不好。 Twitter API公开了两个用于搜索趋势的端点:
如果有趋势信息,则返回特定WOEID的前50个趋势主题。
响应是趋势对象的数组,这些对象编码趋势主题的名称,可用于在Twitter Search上搜索主题的查询参数以及Twitter搜索URL。
此信息被缓存5分钟。要求更多的次数将不会返回更多数据,并且将计入速率限制使用。
如果有可用的趋势,还会返回最近24小时的tweet_volume。
尽管查看返回示例:
"trends": [
{
"name": "#ChainedToTheRhythm",
"url": "http://twitter.com/search?q=%23ChainedToTheRhythm",
"promoted_content": null,
"query": "%23ChainedToTheRhythm",
"tweet_volume": 48857
}
如果您要像这样上课:
public class Trend {
public string name {get; set;}
public string url {get; set;}
// etc
}
然后将数组deserialize移至列表List<Trend>
,可以在内存linq中使用它按名称搜索
var trends = JsonConvert.DeserializeObject<TrendsResponse>(json);
var newTrendList = trends.Where(t = t.name.Contains("targetName")).ToList();