Skip to content

Instantly share code, notes, and snippets.

@ElemarJR
Created August 1, 2012 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElemarJR/3226689 to your computer and use it in GitHub Desktop.
Save ElemarJR/3226689 to your computer and use it in GitHub Desktop.
public async Task<IEnumerable<string>> GetLinksFromMsdnAsync()
{
var response = await new WebClient().
DownloadStringTaskAsync("http://msdn.microsoft.com/pt-br/");
var regex = "href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))";
return Regex.Matches(response, regex)
.OfType<Match>()
.Select(m => m.Groups[1].Value);
}
public async void PrintLinksFromMSDNAsync()
{
var links = await GetLinksFromMsdnAsync();
foreach (var link in links)
Console.WriteLine(link);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment