首页  |  讨论区  |  Java文栏  |  Java源代码  |  Java开源  |  Java下载  |  Web开发  |  数据库技术  |  编程语言  |  Linux  |  业界  |  Wiki
 首页 » Web开发 » ASP
XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码
    发表于:2005-08-02  来自:CSDN   阅读:

Google
 
XMLHTTP的应用,获得远程的文件,获得远程HTML文件源码 - IdeaGrace | Web开发 | ASP,IdeaGrace,web,开发,技术,交流,教程 - http://www.ideagrace.com/
获得远程的文件

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">


喜欢本文?那就在线订阅更多文章更新吧!
加入技术论坛讨论
访问IdeaGrace开发者博客
浏览更多java开源项目
IdeaGrace开发者Wiki

更好的浏览体验,


关于Idea Grace | 版权声明 | 联系我们 | 友情链接
©2008 Idea Grace