Get HTML code from website in C# -


how html code website, save it, , find text linq expression?

i'm using following code source of web page:

public static string code(string url) {     httpwebrequest myrequest = (httpwebrequest)webrequest.create(url);     myrequest.method = "get";     webresponse myresponse = myrequest.getresponse();     streamreader sr = new streamreader(myresponse.getresponsestream(), system.text.encoding.utf8);     string result = sr.readtoend();     sr.close();     myresponse.close();      return result;  } 

how find text in div in source of web page?

getting html code website. can use code this.

string urladdress = "http://google.com";  httpwebrequest request = (httpwebrequest)webrequest.create(urladdress); httpwebresponse response = (httpwebresponse)request.getresponse();  if (response.statuscode == httpstatuscode.ok) {   stream receivestream = response.getresponsestream();   streamreader readstream = null;    if (response.characterset == null)   {      readstream = new streamreader(receivestream);   }   else   {      readstream = new streamreader(receivestream, encoding.getencoding(response.characterset));   }    string data = readstream.readtoend();    response.close();   readstream.close(); } 

this give returned html code website. find text via linq not easy. perhaps better use regular expression not play html code


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -