How to get page source (ex: html, aspx, php) in C#?
like this:
<head>
<title>Ask a Question - Stack Overflow</title>
<link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/favicon.ico">
<link rel="apple-touch-icon" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">
<link rel="search" ty开发者_开发百科pe="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
The simplest way would be to create a WebClient object and call its DownloadString method, although if you need anything other than a simple request/response, you may have to use HttpWebRequest to craft your request.
Not exactly sure what's being asked, but don't you just want to open a tcp connection to the correct port (typically 80) of the webserver, write a 'POST' of the correct variety and then read the response data?
If so, look for http helper classes/libraries that are available in C#
you can use httpwebrequest class or webclient class, its in system.net namespace.
WebClient client = new WebClient();
UTF8Encoding encoding1 = new UTF8Encoding();
byte[] downloadDataInBytes = client.DownloadData("http://negaweblog.wordpress.com");
string websitesource = encoding1.GetString(downloadDataInBytes);
精彩评论