Beispiel #1
0
 public List<Tweet> GetTweetList(string userName, int count, string source)
 {
     List<Tweet> tweets = new List<Tweet>();
     foreach (Match match in Regex.Matches(source, "(?<=<table class=\"tweet).*?(?=<\\/table>)", RegexOptions.Singleline))
     {
         // TODO: Handle emoji characters
         Tweet tweet = new Tweet()
         {
             AuthorUsername = Regex.Match(match.Value, "(?<=<span>@<\\/span>).*(?=\\s*<\\/div>)").Value,
             AuthorName = Regex.Match(match.Value, "(?<=<strong class=\"fullname\">).*(?=<\\/strong>)").Value,
             Content = StripTags(Regex.Match(match.Value, "(?<=<div class=\"dir-ltr\" dir=\"ltr\">).*(?=\\s*<\\/div>)").Value.Trim()),
             Id = Regex.Match(match.Value, "(?<=<div class=\"tweet-text\" data-id=\")\\d+(?=\">)").Value,
             //Date = Regex.Match(match.Value, "(?<=<time datetime=\")[\\s\\S]*(?=\">)").Value
         };
         tweets.Add(tweet);
     }
     return tweets;
 }
 private void PrintTweet(Tweet tweet)
 {
     Console.ForegroundColor = ConsoleColor.Cyan;
     Console.WriteLine("@{0}", tweet.AuthorUsername);
     Console.ForegroundColor = ConsoleColor.DarkGray;
     Console.WriteLine(tweet.AuthorName);
     Console.ResetColor();
     Console.WriteLine(tweet.Content);
     Console.ForegroundColor = ConsoleColor.DarkGray;
     Console.WriteLine("[{0}]", tweet.Id);
     Console.ResetColor();
 }