UIWebView中运行javascript的方法得到网页的html内容
来源:互联网 发布:淘宝主账号修改密码 编辑:程序博客网 时间:2024/05/17 06:05
原文地址:http://blog.csdn.net/favormm/archive/2010/10/19/5950993.aspx
本篇介绍的方法是通过运行javascript的方法得到网页的html内容:
获取所有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];
通过执行javascript的方法实现。下面列出更多javascript的方法:
JavaScript获取当前页面URL、title等,具体怎么用就看自己了~
由于本站用了伪静态,所以获取不到文档名,请[点击这里 ] 然后运行代码查看完整获取,document.location.port;是获取URL关联的端口号码,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;//获取网页内容文字
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/favormm/archive/2010/10/19/5950993.aspx
- UIWebView中运行javascript的方法得到网页的html内容
- WKWebView和UIWebView查看访问网页html内容的方法
- UIWebView中获取网页输入的内容
- UIWebView中获取网页输入的内容
- 网页制作中得到文本编辑器内容的方法
- UIWebView中获取网页输入框的内容
- UIWebView加载网页、文件及html的方法
- iOS中UIWebView与其中网页的javascript的交互
- ios中UIWebView加载本地HTML,以及其中的JavaScript方法的调用
- UIWebView 加载网页的方法
- 计算UIWebView加载网页的内容高度
- iOS 让HTML网页内容和图片自适应UIWebView的宽度
- 利用Javascript去操作UIWebView的内容
- iPhone中获取UIWebView内的html方法
- Javascript中得到各种高度的方法
- 得到一个网页的纯文字内容
- UIWebView访问网页适应手机屏幕的方法
- JavaScript获取网页中HTML元素的几种方法分析javascript
- 值得一看的经典语录
- 串口通信之控件注册
- 超级终端自动登录
- JS操作iframe里的dom,js iframe
- Web开发人员应当知道的15个开源项目
- UIWebView中运行javascript的方法得到网页的html内容
- 在VC中彻底玩转Excel(转)
- 一个ClassLoader的简单例子
- “云”是什么?
- 不要做浮躁的嵌入式工程师
- php mail函数 subject乱码
- Moodle开发笔记7-Activity module开发
- sort多列同时排序
- POJ 1085 Triangle War 极小极大值算法+α-β剪枝