iOS-07-iOS获取UIWebView中的网页信息

作者: 小东门儿 | 来源:发表于2016-07-28 12:24 被阅读721次

JavaScript获取网页信息总结JavaScript获取当前页面URL、title等,
thisHash = document.location.hash;是获取链接属性中在井号“#”后面的分段。
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;//获取网页内容文字
thisBodyText = document.body.innerText; //获取网页内容文字

举个例子

获取所有
html:NSString *lJs = @"document.documentElement.innerHTML";
获取网页
title:NSString *lJs2 = @"document.title";
UIWebView *lWebView = [self getCurrentWebView];
NSString *lHtml1 = [lWebView stringByEvaluatingJavaScriptFromString:lJs];
NSString *lHtml2 = [lWebView stringByEvaluatingJavaScriptFromString:lJs2];
在实际用途中 在webView的代理中使用,当webView加载完成时获取网页信息保存成NSString,过滤文字信息,可以重新加载webView。

相关文章

  • iOS-07-iOS获取UIWebView中的网页信息

    JavaScript获取网页信息总结JavaScript获取当前页面URL、title等,thisHash = d...

  • WKWebView之标题获取

    UIWebView时获取网页标题是在网页加载成功后执行"document.title"js代码来获取标题,WKWe...

  • 爬取NCBI中GEO中的数据

    获取GEO中GSE网页的信息 获取GEO中GSM的信息 汇总写成函数 获取附加材料文件

  • 网页跳转相关

    一、Safari中打开网页 二、UIWebView 三、WKWebView WKWebView比UIWebView...

  • 获取网页信息

    // thisURL = document.URL;// thisHREF = document.lo...

  • UIWebView常用的代理方法

    大道至简 UIwebView UIWebView常作为加载网页的容器,在IB中可以便捷的创建UIWebView控件...

  • Python 爬虫第一篇(urllib+regex)

    爬虫的主要用途即从网站上获取网页,并将网页中的有用信息解析出来。从网站上获取网页内容可以通过 python 内置的...

  • WebView的那些事

    1.简单认识 UIWebView用于在App中嵌入网页内容,通常情况下是html格式的网页 2.UIWebView...

  • urllib

    urllib是获取网页信息的库。 下面的例子1是提取百度首页的网页信息。例子1: 有时候需要提交表单获取网页信息,...

  • 2018-09-13爬虫——数据大盗

    Urllib库 什么是Urllib? 它是python自带的标准库,主要用它来获取网页信息。 怎么获取网页信息??...

网友评论

    本文标题:iOS-07-iOS获取UIWebView中的网页信息

    本文链接:https://www.haomeiwen.com/subject/ntsajttx.html