Ok so i am trying to extract all the links from the google homepage via regular expressions.
But i am facing a baffling problem. When i send the request to the google homepage and try to extract all the links from the page i usually get one result and rest is garbage. However when i manually view the source of the page and extract some link to test against the pattern it works.
Now i don't know what is wrong here i think my pattern is flawed, i am trying hard to get it right or maybe google is sending different responses to my code and browser. I really appreciate if i can get some insight into this problem.
My pattern
string pattern = @"=("")?(https?:\/\/)?[\w.-]+\.[\w]*([/]?[\w]*)*("")?";
My display code
Match match = Regex.Match(source, pattern);
if (match.Success)
{
foreach (var res in match.Groups)
{
Console.WriteLine(res);
}
Console.ReadKey();
}