I have my company's site which works on intranet, Only company's employee can view this site. Now I need to write a code through which I can get all the links from one particular page of our website. Below code isn't working in my case.
using (var client = new System.Net.WebClient())
{
client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
client.Headers.Add("User-Agent: Other");
client.Headers.Add(System.Net.HttpRequestHeader.Cookie, "security=true");
client.Credentials = CredentialCache.DefaultCredentials;
string pattern = @"(<a.*?>.*?</a>)";
MatchCollection hreflist;
string Url = client.DownloadString("https://collaborate.citi.net/docs/DOC-908807");
//Getting the count for the number of links in oldUrl
hreflist = Regex.Matches(Url, pattern);
I am struggling with this line:
string Url = client.DownloadString("https://collaborate.citi.net/docs/DOC-908807");
Is there any better way to achieve this? Please i am struggling with this and your small help or suggestion can help me in many ways