Here is an example function to get the full html output code of an URL provided to the function into a string.
You can get the data by using a string variable which gets the output:
string variable = gethtmlcontent("https://thisisapage");
public string gethtmlcontent(String URL)
{
HttpWebRequest request;
HttpWebResponse response;
try
{ request = (HttpWebRequest)WebRequest.Create(URL);
response = (HttpWebResponse)request.GetResponse();
} catch (WebException) { this.searchcode = false; return null; }
catch (Exception) { this.searchcode = false; return null; }if (response.StatusCode == HttpStatusCode.OK)
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream;
if (String.IsNullOrWhiteSpace(response.CharacterSet)){
readStream = new StreamReader(receiveStream);}
else {readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));}
string data = readStream.ReadToEnd();
response.Close();
readStream.Close();
return data;
}
this.contextcode = false;
response.Close();
return null;
}