twitter4j - setSince 和 setUntil 不起作用 [英] twitter4j - setSince and setUntil don't work
问题描述
我在按特定日期过滤推文时遇到问题,使用 setUntil 没有推文,使用 setSince 来最近推文.. 代码如下,然后是输出结果..
public void readTweetFromKeyword(String keywordString) 抛出 TwitterException{twitter4j.Query 查询 =new twitter4j.Query("#clt20");查询结果结果;query.setSince("2014-12-12");int cont = 0;结果 = twitter.search(query);for(状态状态:result.getTweets()){System.out.print("原始"+status.getId());System.out.println("\t\tdata "+status.getCreatedAt());if(!status.getText().substring(0, 2).equals("RT")){System.out.println(status.getText());续++;}}System.out.println(result.getTweets().size());System.out.println("cont = "+cont);返回;}
控制台:
<块引用>原始 619433499116896256 数据 2015 年 7 月 10 日星期五 06:10:29 GMT-03:00如果@BCCI 正在寻找#Clt20 的替代方案,那么只由印度球员组成的球队联盟?
原始 619408117495939072 数据 2015 年 7 月 10 日星期五 04:29:37 GMT-03:00#TestT、#ODI、#T20I、#IPL、#CLT20 现场记录、得分、历史记录 ke lia,关注@PTV_SpOrtsOne 至 40404.
原始 619330143258050560 数据 Thu Jul 09 23:19:47 GMT-03:00 2015需要 6 个球中的 66 个.有点不可能#clt20
原始 619301555532120065 数据 2015 年 7 月 9 日星期四 21:26:11 GMT-03:00Kamran Akmals 的脚被卡住了 #soshit #CLT20
原始 619095093962608640 数据 Thu Jul 09 07:45:47 GMT-03:00 2015
原始 619095079983017984 数据 Thu Jul 09 07:45:43 GMT-03:00 2015
原始 619095051524665344 数据 Thu Jul 09 07:45:37 GMT-03:00 2015
原始 619095028304973825 数据 Thu Jul 09 07:45:31 GMT-03:00 2015
原始 619094989943902209 数据 Thu Jul 09 07:45:22 GMT-03:00 2015
原始 619094910516400129 数据 Thu Jul 09 07:45:03 GMT-03:00 2015
原始 619094893441363969 数据 Thu Jul 09 07:44:59 GMT-03:00 2015
原始 619035151578722304 数据 Thu Jul 09 03:47:35 GMT-03:00 2015如果你去的话,@abhisek_taneja Games r 每年都会在喜马偕尔邦玩通过#IPL & 的时间表#CLT20 正确
原始 618914815730290688 数据 2015 年 7 月 8 日星期三 19:49:25 GMT-03:00
原始 618908444939186177 数据 2015 年 7 月 8 日星期三 19:24:06 GMT-03:00
原始 618862474687705088 数据 2015 年 7 月 8 日星期三 16:21:26 GMT-03:00我们作为#T20 的追随者,@clt20 应该被组织起来#CLT20
15 连续 = 6
非常感谢!!
如果你设置了一个截止日期,请记住这来自 文档
<块引用>返回在给定日期之前生成的推文.日期应该是格式为 YYYY-MM-DD.请记住,搜索索引可能不会去回到您在此处指定的日期.
还有这个
<块引用>在参与之前,重要的是要知道 Search API 是关注相关性而不是完整性.这意味着一些推文并且用户可能会从搜索结果中丢失.如果你想匹配完整性,您应该考虑改用 Streaming API.
因此,如果您设置的截止日期太旧,您可能会收到零条推文,另一方面,如果您设置的自日期太旧,您在进入控制台时只能收到过去几天的推文.>
I'm having problem to filter tweets by specifics dates, using setUntil come no tweets, using setSince come recently tweets.. The code is following and after that the output result..
public void readTweetFromKeyword(String keywordString) throws TwitterException
{
twitter4j.Query query =new twitter4j.Query("#clt20");
QueryResult result;
query.setSince("2014-12-12");
int cont = 0;
result = twitter.search(query);
for (Status status : result.getTweets() )
{
System.out.print("original "+status.getId());
System.out.println("\t\tdata "+status.getCreatedAt());
if(!status.getText().substring(0, 2).equals("RT")){
System.out.println(status.getText());
cont++;
}
}
System.out.println(result.getTweets().size());
System.out.println("cont = "+cont);
return;
}
CONSOLE:
original 619433499116896256 data Fri Jul 10 06:10:29 GMT-03:00 2015 If the @BCCI is looking for an alternative to #Clt20, then how about a league of teams consisting of only Indian players ?
original 619408117495939072 data Fri Jul 10 04:29:37 GMT-03:00 2015 #TesT, #ODI, #T20I, #IPL, #CLT20 Live record, score, history shedule ke lia, Follow @PTV_SpOrtsOne snt to 40404.
original 619330143258050560 data Thu Jul 09 23:19:47 GMT-03:00 2015 Need 66 From 6 Balls. Kinda Impossible #clt20
original 619301555532120065 data Thu Jul 09 21:26:11 GMT-03:00 2015 Kamran Akmals feet are stuck #soshit #CLT20
original 619095093962608640 data Thu Jul 09 07:45:47 GMT-03:00 2015
original 619095079983017984 data Thu Jul 09 07:45:43 GMT-03:00 2015
original 619095051524665344 data Thu Jul 09 07:45:37 GMT-03:00 2015
original 619095028304973825 data Thu Jul 09 07:45:31 GMT-03:00 2015
original 619094989943902209 data Thu Jul 09 07:45:22 GMT-03:00 2015
original 619094910516400129 data Thu Jul 09 07:45:03 GMT-03:00 2015
original 619094893441363969 data Thu Jul 09 07:44:59 GMT-03:00 2015
original 619035151578722304 data Thu Jul 09 03:47:35 GMT-03:00 2015 @abhisek_taneja Games r played in Himachal Pradesh every year if u go through the schedule of #IPL & #CLT20 properly
original 618914815730290688 data Wed Jul 08 19:49:25 GMT-03:00 2015
original 618908444939186177 data Wed Jul 08 19:24:06 GMT-03:00 2015
original 618862474687705088 data Wed Jul 08 16:21:26 GMT-03:00 2015 We as #T20 follower , @clt20 should be oganized #CLT20
15 cont = 6
Thanks a lot!!
If you set an until date kepp in mind this from the documentation
Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. Keep in mind that the search index may not go back as far as the date you specify here.
And this too
Before getting involved, it’s important to know that the Search API is focused on relevance and not completeness. This means that some Tweets and users may be missing from search results. If you want to match for completeness you should consider using a Streaming API instead.
So, if you set an until date too old you could get zero tweets, in the other hand if you set a since date too old you could get only tweets from the few past days as you get in the console.
这篇关于twitter4j - setSince 和 setUntil 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!