Beispiel #1
0
 static void Main(string[] args)
 {
     var twitter = new TwitterSearch();
     foreach (var tweet in twitter.Search(100, "data","visualization")) {
         Console.WriteLine(tweet);
         Regex linkParser = new Regex(@"\b(?:http://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
         foreach (Match m in linkParser.Matches(tweet.Text)) {
             var fullUrl = m.Value.ExpandUrl();
             var scraper = new PageScraper(fullUrl);
             foreach (var img in scraper.GetImages()) {
                 Debug.Print(img);
             }
         }
     }
 }
Beispiel #2
0
 public IEnumerable<string> Fetch(params string[] query)
 {
     HashSet<string> seenUrls = new HashSet<string>();
     var twitter = new TwitterSearch();
     foreach (var tweet in twitter.Search(10, 1, query)) {
         Regex linkParser = new Regex(@"\b(?:http://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
         foreach (Match m in linkParser.Matches(tweet.Text)) {
             var fullUrl = m.Value.ExpandUrl();
             Debug.Print(fullUrl);
             if (seenUrls.Contains(fullUrl)) {
                 continue;
             }
             var scraper = new PageScraper(fullUrl);
             foreach (var img in scraper.GetImages()) {
                 yield return img;
             }
             seenUrls.Add(fullUrl);
         }
     }
 }