我想使用标签搜索过去一周的推文。
例如,如果我在文本框中写“Google”,代码应返回每条包含“Google”字样的推文,并且在过去7天内发布,无论是谁发布了推文。
我能够获取过去一小时的数据,但我想阅读过去一周的数据。这是我的代码
public static void GetTweet(String query)
{
DateTime Pre = DateTime.Now.AddDays(-7);
SearchOptions options = new SearchOptions(){
SinceDate = Pre,
PageNumber=pageNumber,
NumberPerPage =100
};
TwitterResponse<TwitterSearchResultCollection> searchResult = TwitterSearch.Search(query,options);
while (searchResult.Result == RequestResult.Success && pageNumber < 10)
{
foreach (var tweet in searchResult.ResponseObject)
{
Console.WriteLine(tweet.Text, tweet.CreatedDate);
pageNumber++;
searchResult = TwitterSearch.Search(query, options);
}
}
}
答案 0 :(得分:0)
Twitter API并非旨在为您提供这样的数据,尤其是在查询类似的大型数据集时。每个端点都有自己的局限性。一般来说,这是过去两周内的2000条推文。
搜索API允许您最多获得1500条推文(15页,每页100条)。
答案 1 :(得分:0)
你可以做这样的事情
Dim s As New UserTimelineOptions
s.Count = 3000
s.UseSSL = True
s.APIBaseAddress = "http://api.twitter.com/1/"
s.IncludeRetweets = False
s.UserId = 24769625 'Just a sample account
Dim T As TwitterResponse(Of TwitterStatusCollection) = TwitterTimeline.UserTimeline(tokens, s)
For Each Tweet As TwitterStatus In T.ResponseObject
Console.WriteLine(Tweet.User.ScreenName & ": " & Tweet.Text)
'In here just check the created date on the tweet.createddate and look for the time frame
Next