XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码
2005-07-23 10:21
447 查看
收藏说明 内容无修改 重新排版
本文来自 kingwkb的专栏
原文地址 http://blog.csdn.net/mind_1220/archive/2005/07/22/431786.aspx
------------------------------------------
大灰狼的ASP工具箱——XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码
获得远程的文件
response.write getHTTPPage("http://www.csdn.net")
function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Msxml2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then exit function
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
--------------------------------------------------------------------
获得远程HTML文件源码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body>
<div id="demo"> <div style="width: 677; height: 70">
</body>
</html>
<script language=vbscript>
sub b3_onclick
Dim objXMLHTTP, xml
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://192.168.8.15:7001/wap_manage/login.asp", False
' Pull the data from the web page
xml.Send
'demo.innerhtml= xml.responseText
'demo.innertext= xml.responseText
demo.innertext= bytes2BSTR(xml.responsebody)
Set xml = Nothing
end sub
sub d1_select
end sub
Function bytes2BSTR(vIn)
Dim strReturn
Dim I, ThisCharCode, NextCharCode
strReturn = ""
For I = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn, I, 1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn, I + 1, 1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
I = I + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<input type="button" value="获取html源码" name="B3">
本文来自 kingwkb的专栏
原文地址 http://blog.csdn.net/mind_1220/archive/2005/07/22/431786.aspx
------------------------------------------
大灰狼的ASP工具箱——XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码
获得远程的文件
response.write getHTTPPage("http://www.csdn.net")
function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Msxml2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then exit function
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
--------------------------------------------------------------------
获得远程HTML文件源码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body>
<div id="demo"> <div style="width: 677; height: 70">
</body>
</html>
<script language=vbscript>
sub b3_onclick
Dim objXMLHTTP, xml
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://192.168.8.15:7001/wap_manage/login.asp", False
' Pull the data from the web page
xml.Send
'demo.innerhtml= xml.responseText
'demo.innertext= xml.responseText
demo.innertext= bytes2BSTR(xml.responsebody)
Set xml = Nothing
end sub
sub d1_select
end sub
Function bytes2BSTR(vIn)
Dim strReturn
Dim I, ThisCharCode, NextCharCode
strReturn = ""
For I = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn, I, 1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn, I + 1, 1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
I = I + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<input type="button" value="获取html源码" name="B3">
相关文章推荐
- XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码
- 大灰狼的ASP工具箱——XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码
- XMLHTTP检测远程文件存在与否
- Launcher 源码有关加载应用xml等资源文件研究
- Heritrix1.14源码分析(3) 修改配置文件order.xml加快你的抓取速度
- XMLHttpRequest实现HTTP协议下文件上传断点续传
- JavaScript - XMLHttpRequest 应用示例(传输二进制数据、JSON 字符串,监测进度)
- 【asp】第一个asp文件(ajax技术)XMLHttpRequest,XML
- 通过XMLHttpRequest加载外部图片文件或数据
- web应用和web.xml文件的一点知识点
- Android 网络应用重点———使用HttpGet 下载apk文件并安装
- C#获取远程xml文件
- XMLHttpRequest文件上传,并显示进度条
- 源码公开的TCP/IP协议栈在远程监测中的应用
- 使用HttpWebRequest以及HttpWebResponse读取Http远程文件
- Http协议+java httpURLConnetion实现远程读取文件+chrome DEBUG Timing
- asp xmlhttp 读取文件
- 带进度条的HTML5上传文件(使用XMLHttpRequest对象
- 桌面应用也可以提供HTTP文件下载
- VC利用http远程下载文件