UIWebView通过JS语句获取网页(html)的某些数值

//To get string from the title of the HTML page:
NSString *currentURL = [theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('title')[0][removed];"];
//To get string from class name:
NSString *someHTML = [theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('class name')[0][removed];"];
//To get string from element id:
NSString *html = [theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('div id').textContent=''"];

 

posted @ 2016-03-08 12:32  刚刚888  阅读(244)  评论(0编辑  收藏  举报