本文整理汇总了C#中Twitter.populateData方法的典型用法代码示例。如果您正苦于以下问题:C# Twitter.populateData方法的具体用法?C# Twitter.populateData怎么用?C# Twitter.populateData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twitter
的用法示例。
在下文中一共展示了Twitter.populateData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
String ini;
if (args.Length < 1) {
Console.WriteLine("Please enter the name of the ini file");
ini = Console.ReadLine();
}
else
ini = args[0];
Console.WriteLine(ini);
var twit = new Twitter(ini);
//twit.testStream();
var testCount = 100;
twit.populateData(testCount);
while (twit.Data.Count() < testCount - 1) {
Console.WriteLine(twit.Data.Count());
System.Threading.Thread.Sleep(5000);
}
twit.writeDateToFile(@"C:\Users\Kevin\Documents\TestJson\data.txt");
//twit.testStream("Disney");
Tweets data = new Tweets();
JsonSerializer serializer = new JsonSerializer();
serializer.NullValueHandling = NullValueHandling.Ignore;
using (StreamReader sr = new StreamReader(@"C:\Users\Kevin\Documents\TestJson\data.txt"))
using (JsonTextReader jr = new JsonTextReader(sr)) {
if(!jr.Read() || jr.TokenType != JsonToken.StartArray) {
throw new Exception("Expected start of array");
}
while (jr.Read()) {
if (jr.TokenType == JsonToken.EndArray) break;
var item = serializer.Deserialize<TweetData>(jr);
data.add(item);
}
}
Console.WriteLine("done");
foreach (var tweet in data) {
Console.WriteLine(tweet.text);
}
//twit.getData();
//while (twit.Data.Length <= 1) ;
//Console.WriteLine(twit.Data+"\n");
//Twitter.testStream(ini);
var news = new News();
news.getGoogleNews("Disney");
foreach (var article in news.Data) {
Console.WriteLine(article.Title+" "+article.publishData.ToString() );
}
Console.WriteLine("Done with everything");
Console.ReadLine();
}
示例2: Main
static void Main(string[] args)
{
List<string> terms = new List<string>();
var options = new Options();
var result = CommandLine.Parser.Default.ParseArguments(args, options);
var twit = new Twitter(options.ini);
Console.WriteLine("Connected to twitter");
var news = new News();
string date = DateTime.Now.ToString("M-d-yyyy");
if (!Directory.Exists(options.twitterStore + date)) {
Directory.CreateDirectory(options.twitterStore + date);
}
if (!Directory.Exists(options.newsStore + date)) {
Directory.CreateDirectory(options.newsStore + date);
}
//TODO do the same for the news articles
string time = DateTime.Now.ToString("HHmmss");
foreach (var x in options.terms) {
string path = options.twitterStore +date;
string fileName = time+"-"+x+".txt";
string file = Path.Combine(path, fileName);
twit.populateData(x, options.tweetCount);
while (twit.Data.Count() < options.tweetCount - 1) {
System.Threading.Thread.Sleep(5000);
Console.WriteLine("Topic:"+x +" count="+twit.Data.Count());
}
Console.WriteLine("Collection for " + x + " done, writing to file.");
twit.writeDateToFile(file);
Console.WriteLine("Writing file done");
}
Console.WriteLine("collecting generic data");
twit.populateData(1000);
while (twit.Data.Count() < 1000 - 1) {
System.Threading.Thread.Sleep(5000);
Console.WriteLine("Count=" + twit.Data.Count());
}
twit.writeDateToFile(Path.Combine(options.twitterStore+date, time+".txt"));
foreach (var x in options.terms) {
string path = options.newsStore + date;
string fileName = time + "-" + x + ".txt";
string file = Path.Combine(path, fileName);
news.getGoogleNews(x);
news.writeDateToFile(file);
}
Console.WriteLine("Collection Done");
Console.ReadLine();
}