Big Wolf ASP Toolbox--xmlhttp application, get remote file, get remote HTML file source

Source: Internet
Author: User
Tags chr microsoft frontpage
Xml|xml

Get a remote file

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

--------------------------------------------------------------------

Get Remote HTML file source

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

<body>
<div id= "Demo" > <div style= "width:677; Height:70 ">

</body>

<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= "Get HTML Source" name= "B3" >




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.