I am working on c# and am grabbing only links (an example) to the downloaded html code.
I know that I have the code of the website in the string htmlcode.
However I can't seem to get this to allow me to put match into a string. Below is my code:
public string getURL()
{
/* Web client being opened up and being ready to read */
WebClient webclient = new WebClient();
Uri URL = new Uri("http://www.pinkbike.com");
string htmlcode = webclient.DownloadString(URL);
/* Time to grab only the links */
string pattern = @"a href=""(?<link>.+?)""";
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection MC = regex.Matches(htmlcode);
string htmlcode1;
foreach(Match match in MC)
{
/* Error location */
htmlcode1 = match.Groups["link"];
}
return htmlcode1;