Is there an easy way to read the external source of a webpage? ASP.NET

Id like to write a function that reads an external news site and returns the source code of the landing page. Any ideas and / or information to get me started?

+1


source to share


3 answers


string GetOtherPage(System.Uri url)
{
    return new System.Net.WebClient().DownloadString(url);
}

      



+7


source


You can have a look at System.Net.WebRequest class and sample



But please don't do such crappy code like MSDN sample yourself, use using idioms where necessary

+1


source


If you are talking about HTML source, then Joel's answer is correct.

However, if you're talking about the actual code for dynamic pages, the answer is "thankfully no". Most properly configured sites do not return source code that is dynamically executed to create the page.

0


source







All Articles