java - Extracting tweets of a specific hashtag using twitter4j -


I am able to remove tweets from a specific hashtag using the Search method as below

  twitter4j.Twitter Twitter = TwitterFactory.getSingleton (); Query query = new query ("ipl7"); Query result result = twitter.search (query); (Status status: result.getTweets ()) {System.out.println ("@" + status.getUser (). GetScreenName () + ":" + status.getText () + ":" + status.getGeo place ( )); }  

However, I have received very limited tweets using the above method. What changes should I make to get all the Tweets of specific hashtags?

You can use the streaming API to get a recent set of keywords by recently Tweets in your case You only have one keyword that hashtag, right? I posted a brief sample code to search for tweets with a keyword with the streaming API. You can use both streaming and search APIs for different purposes. Mostly you can use Search API for Hosteric Tweets for a limited time. This allows you to give a date interval. However, you can use the Streamin API to capture recently posted Tweets as a tweetor stream, which includes the keywords you provided.

Examples of the following stamming codes:

  Private static zero GetTweetStreamForKeywords () {TwitterStream twitter stream = new TwitterStreamFactory (config) .getInstance (); StatusListener StatusLijer = New StatusListener () {@OverrideStatus Public Zero (Status Position) {// You get Tweet that main section. You can access it by status object. // You can save it in the database table. } @parride public null at the delegation notice (Status Declaration Notice SDN) {new unsupported operation throw exception ("Not yet supported"); } Override public zero over @TrackLimitationNotice (int i) throw a new unsupported operation exception ("Not yet supported."); } Override public null at @ScrubGeo (long, long L1) {New unsupported operation throw exception ("Not yet supported."); } @OnRride PublicWide on Stall Warning {new unsupported operation throw exception at throw stare at "Storing Warning" ("Not yet supported."); } @ Override Exceptions on Public Zero (Exception Preceded by) {logWriter.WriteErrorLog (Formerly, "onException ()"); }}; FilterQuery fq = new filterclub (); String keyword [] = {"sports", "politics", "health"}; Fq.track (keywords); TwitterStream.addListener (statusListener); TwitterStream.filter (fq); }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -