I want to get content from a specific URL. I tried this code:
var request = (HttpWebRequest)WebRequest.Create("https://example.com");
request.Timeout = 5000;
request.Method = "GET";
request.ContentType = "text/xml";
using (var _webResponse = (HttpWebResponse)_request.GetResponse())
{
var webResponseStatus = _webResponse.StatusCode;
var stream = _webResponse.GetResponseStream();
using (var _streamReader = new StreamReader(_stream))
{
string plainText = _streamReader.ReadToEnd();
}
}
The problem is that the content is not relevant, it seems like it returns block of garbage. For example, this is the beginning of the content I receive:
<!doctype html><html itemscope=\"\"
itemtype=\"http://schema.org/WebPage\" dir=\"rtl\"><head><meta
itemprop=\"image\"
content=\"/images/google_favicon_128.png\"><title>Google</title><script>(function(){\nwindow.google={kEI:\"JVMWU4OxMuL9ygOem4GACw\",getEI:function(a){for(var
b;a&&(!a.getAttribute||!(b=a.getAttribute(\"eid\")));)a=a.parentNode;return
b||google.kEI},https:function(){return\"https:\"==window.location.protocol},kEXPI:\"17259,4000116,4007661,4007830,4008067,4008133,4008142,4009033,4009565,4009641,4010297,4010806,4010830,4010858,4010899,4011228,4011258,4011679,4012318,4012373,40125
I want to get the text which displayed in the webpage. How do I do this ? I'll be thankful for any help. Thank you, Avi.