twitter - all the tweets in a specific period of time with Java -
this question has answer here:
- is possible more 100 tweets? 6 answers
- how retrieve more 100 results using twitter4j 4 answers
i'm trying extract , save tweets in specific period of time specific hashtag #obama twitter in java using twitter4j.
time = 2017-01-01 2017-03-01
hashtag = #obama
i need of tweets in period of time gives me 100 tweets.
query.setuntil("2017-03-01"); doesn't work
public class main5 { private final static string consumerkey = "********************"; private final static string consumersecret = "****************************************"; private final static string accesstoken = "****************************************"; private final static string accesstokensecret = "****************************************"; public static void main(string[] args) throws twitterexception { configurationbuilder configurationbuilder = new configurationbuilder() .setdebugenabled(true) .setoauthaccesstokensecret(accesstokensecret) .setoauthaccesstoken(accesstoken) .setoauthconsumerkey(consumerkey) .setoauthconsumersecret(consumersecret); twitterfactory twitterfactory = new twitterfactory(configurationbuilder.build()); twitter twitter = twitterfactory.getinstance(); query query = new query("#obama"); query.setcount(10000); query.setsince("2017-01-01"); query.setuntil("2017-03-01"); queryresult result = twitter.search(query); (status status : result.gettweets()) { system.out.println(status.getuser() + "\t" + status.gettext() + "\n\n*********************\n\n"); } system.out.println(result.getcount()); } }
Comments
Post a Comment