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(); }
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(); }