//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=''"];
本文介绍了如何通过iOS中的WebView来获取HTML页面的标题、指定类名的元素及指定ID的元素等内容。利用JavaScript与Objective-C相结合的方式实现跨语言交互,从而达到从网页中抽取所需信息的目的。
1387

被折叠的 条评论
为什么被折叠?



