Reputation: 12560
Id like to be able to write a function that reads an external news site and returns the source code of the target page. Any ideas and/or information to get me started?
Upvotes: 1
Views: 714
Reputation: 415620
string GetOtherPage(System.Uri url)
{
return new System.Net.WebClient().DownloadString(url);
}
Upvotes: 7
Reputation: 12705
If you are talking about the HTML source, then Joel's answer is correct.
However, if you are talking about the actual codebehind for dynamic pages, the answer is "thankfully, no". Most properly configured sites will not return the source code that is dynamically executed to make a page.
Upvotes: 0
Reputation: 2022
You can look at System.Net.WebRequest class and the sample
But please, don't make such crappy code as MSDN sample yourself, use the using idiom where appropriate
Upvotes: 1