我正在使用 twitter4j 从 twitter 中提取推文。我想知道在检索推文后,如何将这些推文写入 csv 文件?非常感谢!
package test;
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;
import java.io.IOException;
import java.sql.*;
import java.util.Calendar;
import java.io.FileWriter;
public class test {
public static void main(String[] args) throws TwitterException, IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, SQLException
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("XXX")
.setOAuthConsumerSecret("XXX")
.setOAuthAccessToken("XX")
.setOAuthAccessTokenSecret("XX");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
Query query = new Query("your keywords");
query.setCount(200);
query.geoCode(new GeoLocation(XX, XXX), 200, Query.KILOMETERS);
QueryResult result = twitter.search(query);
}
}