javascript怎么抓取网页中javascript返回数据

好记忆不如烂笔头abc 2017-09-11 03:03:10
javascript可以通过XMLHttpRequest抓取当前页的源代码,但是怎么抓取网页中有javascript动态返回的具体数据?
比如网页中有动态时间的脚本,怎么抓这个日期,而不是js代码,(各种网页内的脚本不固定):
<script>
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}
document.write(getNowFormatDate());</script>

请高手看看!
...全文
513 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 2 楼 jslang 的回复:
用隐藏的iframe加载页面,在iframe的onload事件中取 document.getElementById("iframeID").contentDocument.body.innerHTML
当前页是父页面怎么加啊?
天际的海浪 2017-09-11
  • 打赏
  • 举报
回复
用隐藏的iframe加载页面,在iframe的onload事件中取 document.getElementById("iframeID").contentDocument.body.innerHTML
hongmei85 2017-09-11
  • 打赏
  • 举报
回复
你发的这个js脚本。日期是抓不到的。

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧