This article describes how to get the HTML content of a Web page by running javascript:
Get all html:nsstring *ljs = @ "Document.documentElement.innerHTML";
Get page title:nsstring *ljs2 = @ "Document.title";
UIWebView *lwebview = [self getcurrentwebview];
NSString *LHTML1 = [Lwebview Stringbyevaluatingjavascriptfromstring:ljs];
NSString *LHTML2 = [Lwebview stringbyevaluatingjavascriptfromstring:ljs2];
Implemented by means of the JavaScript implementation. More JavaScript methods are listed below:
JavaScript gets the current page URL, title, etc., how to use it to see yourself ~
Because this site uses pseudo-static, so get the document name, please [click here] and then run the code to see the full get, document.location.port; is to get the URL associated with the port number, Thishash = Document.location.hash; is to get the segment of the link property that follows the pound sign "#".
Thisurl = document. URL;
Thishref = Document.location.href;
Thissloc = Self.location.href;
Thisdloc = document.location;
Thistloc = Top.location.href;
Thisploc = parent.document.location;
Thisthost = Top.location.hostname;
Thishost = Location.hostname;
Thistitle = Document.title;
Thisprotocol = Document.location.protocol;
Thisport = Document.location.port;
Thishash = Document.location.hash;
Thissearch = Document.location.search;
Thispathname = Document.location.pathname;
thishtml = Document.documentElement.innerHTML;
Thisbodytext = document.documentelement.innertext;//Get page content text
Thisbodytext = document.body.innertext;//Get page content text
Use JS to get UIWebView loaded Web content