当前位置: 首页>>代码示例>>C#>>正文


C# Twitter.writeDateToFile方法代码示例

本文整理汇总了C#中Twitter.writeDateToFile方法的典型用法代码示例。如果您正苦于以下问题:C# Twitter.writeDateToFile方法的具体用法?C# Twitter.writeDateToFile怎么用?C# Twitter.writeDateToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twitter的用法示例。


在下文中一共展示了Twitter.writeDateToFile方法的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();
        }
开发者ID:karashak1,项目名称:ThesisProject,代码行数:54,代码来源:Main.cs

示例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();
        }
开发者ID:karashak1,项目名称:ThesisProject,代码行数:51,代码来源:Program.cs


注:本文中的Twitter.writeDateToFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。