开发者

help with reading text body from a web page

开发者 https://www.devze.com 2023-01-11 01:00 出处:网络
NSString *myText = [webView stringByEvaluatingJavaScriptFromString:@\"document.documentElement.innerText\"];

NSString *myText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerText"]; NSLog(@"my text -> %@",my开发者_C百科Text);

I get all the JavaScript for the webView but what i want is to save the body text only from the web page so can any body help me with some codes or any ideas thanks


Take the innerText of some element in the document, i.e. from body element.


It sounds like you want to get the text of the document excluding the tags.

If the page you're visiting uses JQuery, you could simply use $(body).text() to achieve this.

If not, you may need to strip off the tags with a regular expression yourself. This post seems to have an answer for this problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号