Microsoft.XmlHttp 如何取得带 AJAX的页面的内容

jack_wang0823 2013-01-24 11:51:03


此代码来自梅子论坛
oHttp = NewObject('Microsoft.XmlHttp')
oHttp.open('GET', 'http://city.ip138.com/ip2city.asp?ts='+Sys(2015))
oHttp.send()
Do while oHttp.readyState<>4
Inkey(0.1)
EndDo
cBody = Strconv(oHttp.responseBody,2)
? StrExtract(cBody, '您的IP地址是:[', ']')

经运行 不成功. 检查后 发现 cBody 接受到的是一个框架而非内容
请问如何接收到内容而非框架
...全文
199 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
都市夜猫 2013-01-27
这种类型可能用一个 Web Browser 控件装入页面,然后让它来解析更容易点 1. 新建一个 Form 2. 放入一个 MS Web Browser 控件, 在它的 Init 中装入页面:this.navigate(路由器管理页面) 3. 再放一个按钮,按钮 click 中写代码: Mesagebox(Thisform.Olecontrol1.Document.getElementById('head_ip_ebw').innerText) 试试
  • 打赏
  • 举报
回复
jack_wang0823 2013-01-26
我实际上是用来截取 路由器的WEB 页面

oHttp = NewObject('Microsoft.XmlHttp')
oHttp.open('GET', 'http://192.168.1.1','admin','admin')
oHttp.send()
Do while oHttp.readyState<>4
Inkey(0.1)
EndDo
cBody = Strconv(oHttp.responseBody,2)


返回来的内容是这样的.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="X-UA-Compatible"content="IE=7"/>
<title>磊科(Netcore)宽带路由器管理面板</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/lib_table.css" type="text/css" />
<link rel="stylesheet" href="css/tabctrl.css" type="text/css" />
<!--[if IE]><script language="javascript" type="text/javascript" src="./script/excanvas.min.js"></script><![endif]-->
<script type="text/javascript" src="./script/jquery-1.2.6.js"></script>
<script type="text/javascript" src="./script/jquery.flot.js"></script>
<script type="text/javascript" src="./script/jquery.tab.js"></script>
<script type="text/javascript" src="script/ui_config.js"></script>
<script type="text/javascript" src="./script/lib.js"></script>
<script type="text/javascript" src="./script/ui.js"></script>
<script type="text/javascript" src="./script/libTable.js"></script>
<script type="text/javascript" src="./script/message_panel.js"></script>
<script type="text/javascript" src="./script/cgi_request.js"></script>
<script type="text/javascript" src="./script/err.js"></script>
<script type="text/javascript" src="./script/vpn.js"></script>
<script type="text/javascript" src="./script/user_group.js"></script>
<script type="text/javascript" src="./script/time_segment.js"></script>
<script type="text/javascript" src="./script/action_array.js"></script>
<script type="text/javascript" src="./script/action_control.js"></script>
<script type="text/javascript" src="./script/qq_msn_control.js"></script>
<script type="text/javascript" src="./script/system_status.js"></script>
<script type="text/javascript" src="./script/network_config.js"></script>
<script type="text/javascript" src="./script/network_security.js"></script>
<script type="text/javascript" src="./script/application_service.js"></script>
<script type="text/javascript" src="./script/qos.js"></script>
<script type="text/javascript" src="./script/advance_setup.js"></script>
<script type="text/javascript" src="./script/misc.js"></script>
<script type="text/javascript" src="./script/log.js"></script>
<script type="text/javascript" src="./script/quick_setup.js"></script>
<script type="text/javascript" src="./script/service.js"></script>
</head>
<body>
<div id="lock_div"> </div>
<div id="message_panel"><span id="mess"> </span><br/>
<br/>
<img id="save_jd_gif" src="./images/jd.gif" />
</div>
<center>
<div id="background_layer">
<div id="top_layer" style="position:relative;zoom:1;">
<img src="images/logo.gif" style="float:left"/>
<div id="icon_list">
<div class="icon">
<a href="http://www.netcoretec.com" target="_blank"><img src="images/co.gif" /></a>
<a href="http://www.netcoretec.com" target="_blank">公司网站</a>
</div>
<div class="icon">
<a href="http://www.netcoretec.com/solutions/newsCategoryId=2d422fe9-a647-47d3-8e35-b1055b677d18.html" target="_blank"><img src="images/setup.gif" /></a>
<a href="http://www.netcoretec.com/solutions/newsCategoryId=2d422fe9-a647-47d3-8e35-b1055b677d18.html" target="_blank">安装指南</a>
</div>
<div class="icon">
<a href="http://www.netcoretec.com/products_list/pmcId=a3e1b9c9-34e4-422b-96a6-77749e5d4ced.html" target="_blank"><img src="images/product.gif" /></a>
<a href="http://www.netcoretec.com/products_list/pmcId=a3e1b9c9-34e4-422b-96a6-77749e5d4ced.html" target="_blank">相关产品</a>
</div>
<div class="icon">
<a href="http://www.netcoretec.com/download_list/downloadcategoryid=68b15089-5fe3-43fa-8ad3-8cadc454ab52.html" target="_blank"><img src="images/download.gif" /></a>
<a href="http://www.netcoretec.com/download_list/downloadcategoryid=68b15089-5fe3-43fa-8ad3-8cadc454ab52.html" target="_blank">固件下载</a>
</div>
<div class="icon">
<a href="http://www.netcoretec.com/service/&FrontComContent_list01-serviceContId=d27a1719-552f-4d85-a1f9-e17b349d3807&comContentId=d27a1719-552f-4d85-a1f9-e17b349d3807&comp_stats=comp-FrontComContent_list01-service.html" target="_blank"><img src="images/contact.gif" /></a>
<a href="http://www.netcoretec.com/service/&FrontComContent_list01-serviceContId=d27a1719-552f-4d85-a1f9-e17b349d3807&comContentId=d27a1719-552f-4d85-a1f9-e17b349d3807&comp_stats=comp-FrontComContent_list01-service.html" target="_blank">联系我们</a>
</div>
</div>
<img src="images/logo_text.gif" style="float:right;margin-right:10px"/>
<!--[if IE 6]>
<iframe class="help_iframe"></iframe>
<![endif]-->
<div id="help" class="off"> <a id="help_show" style=" float:right; margin-right:5px; color:#002A70"><b>帮 助</b> <img src="images/help.jpg" style=" margin-bottom:-3px; height: 17px" title="帮助" /></a>
<div id="help_div" class="off">
<div id="help_content"> </div>
<div id="help_hide"><a onclick="help_hide()" style=" margin-left:90px; font-size:12px; color:#666">关 闭 <img src="images/help_cls.jpg" style="margin-bottom:-3px" title="关闭" /></a></div>
</div>
</div>
<!--add-->
<div id="version_ip_time_div" style="position:absolute; right:0; bottom:0; zoom:1; overflow:hidden; width:100%;height:25px;" >
<div style="float:left; font-size:12px;">版本:<span id="versionN" style="font-size:12px; padding-right:8px;"></span></div>
<div style="float:left; font-size:12px;">IP:<span id="head_ip_ebw" style="font-size:12px; padding-right:8px;"></span></div>
<div id="golbal_sys_time" style="float:right; font-size:12px;"></div>
</div>
<!--end-->
</div>
<div id="main_menu_layer">
<div id="main_menu_head"> </div>
<span id="version_span"></span>
<div id="main_menu_control_layer"> </div>
</div>
<div id="map_layer">
<ul>
<li id="map_text">”专注用户需求、推动网络应用”Netcore中国公司将与广大用户一起迎接信息时代的挑战! </li>
</ul>
</div>
<div id="fragment_menu" class="on"> </div>
<div id="content_layer"> </div>
</div>
<div id="bottom_layer">
<div>
<div class="tel"><span style="color:#6C6F71;padding-right:0;">netcore免长途技术服务热线:</span><span>400-810-1616</span><span>开放时间:周一至周日 08:30-18:30</span></div>
<div class="copyright"> <span>CopyRight © Netcore All Rights Reserved.</span><br/></div>
</div>
</div>
</center>
<div id="quick_setup_popdiv" style="z-index:2000"></div>
</body>
<script type="text/javascript">
/*window.onerror = function(){
return true;
} */
$(document).ready( function(){
//alert(window.navigator.userAgent)
init_main_menu();
$("#network_config").click();
//loadhtml("service",function(){});
loadhtml("service",init_load_service);
$("body").mousedown(function(){
var msgbox = new MessageBox();
if(msgbox){
msgbox.Hide();
}
$("#help_show").click(help_show)
});
$.ajaxSetup ({
cache: false //关闭AJAX相应的缓存
});
DataRequest("system_info",{no:"no"},function(data){
var v_st = data.version.split("-")[1];
var v_str = v_st.substring(0,v_st.length-1);
$("#versionN").html(v_str);
//var v_str = data.version.split(")")[0].split('(')[1];
$("#version_span").html(data.model);
$("#version_span").css("font-weight","bold");
});
window.setInterval(function(){
load_time();
},1000);
});
</script>
</html>


在ie中打开 是下面的画面


具体应该去哪个文件呢
  • 打赏
  • 举报
回复
十豆三 2013-01-26
用的不是这个路由器,无法测试。
  • 打赏
  • 举报
回复
都市夜猫 2013-01-25
地址 http://city.ip138.com/ip2city.asp 改成 http://iframe.ip138.com/ic.asp
判断字符串 您的IP地址是:[ 改成 您的IP是:[

这些网页的 asp 代码经常会更新,所以通过截取返回的 html 内容来获取结果的方法也需要同步改变
  • 打赏
  • 举报
回复
lygcw9602 2013-01-25
按照猫老师的思路,代码改为以下,即可达到楼主的要求
oHttp = NewObject('Microsoft.XmlHttp')
oHttp.open('GET', 'http://iframe.ip138.com/ic.asp')
oHttp.send()
Do while oHttp.readyState<>4
   Inkey(0.1)
EndDo
cBody = Strconv(oHttp.responsebody,2)
MESSAGEBOX(StrExtract(cBody,[<body style="margin:0px"><center>], [</center></body></html>]))
  • 打赏
  • 举报
回复
发帖
VFP

2553

社区成员

VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
帖子事件
创建了帖子
2013-01-24 11:51
社区公告
暂无公告