Hello!
I have a URL of a web page and I want to recieve the html source of that page in a string using c#.
how can I do that?
thanks!
:wave:
Printable View
Hello!
I have a URL of a web page and I want to recieve the html source of that page in a string using c#.
how can I do that?
thanks!
:wave:
You can use the System.Net.WebClient class.
Code:using System.Net;
using System.IO;
// ...
// create a new WebClient
WebClient client = new WebClient();
// create a stream which contains the source of the address passed.
Stream webStream = client.OpenRead(@"http://www.google.com");
StreamReader reader = new StreamReader(webStream);
// read the entire stream
string value = reader.ReadToEnd();
// show the source
MessageBox.Show(value);
// clean up
webStream.Close();
reader.Close();