ASP+XMLHTTP取得网页代码
来源:互联网 发布:做动图的软件 编辑:程序博客网 时间:2024/04/28 19:32
<%
'*****************************************************
' Function Name:xmlReadUrl(url)
' 功能:读取Url的HTML
' Input Url
' Output to Function Name xmlReadUrl as a binstr
' ****************************************************
Function xmlReadUrl(url)
Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'Set xml = Server.CreateObject("MSXML2.XMLHTTP")
'Set xml = Server.CreateObject("MSXML2.XMLHTTP.4.0")
xml.Open "GET",url,False
xml.Send '发送请求
'Response.AddHeader "Content-Disposition", "attachment;filename=mitchell-pres.zip" '添加头给这个文件
'Response.ContentType = "application/zip" '设置输出类型
'Response.Binarywrite xml.ResponseBody '输出二进制到浏览器
xmlReadUrl=xml.ResponseBody
Set xml = Nothing
End Function
'*****************************************************
' Function Name:URLEncoding(vstrIn)
' 功能:将URL字符串编码成16进制
' ****************************************************
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
'*****************************************************
'Function Name:Bytes2Str(BStr)
'Convert Bstr to Text Str In Unicode
'*****************************************************
Function Bytes2STR(vIn)
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
Bytes2STR = strReturn
End Function
' Function Name:Bin2Str(binstr)
' 功能:将二进制字符转换成普通字符
' Input binstr as bin stream
' Output to Function Name Bin2Str as a text stream
' ****************************************************
Function Bin2Str(binstr)
Dim binlen,clow,str,skipflag
skipflag=0
str = ""
binlen=LenB(binstr)
For i=1 To binlen
IF skipflag=0 Then
clow = MidB(binstr,i,1)
IF AscB(clow)>127 Then
str =str & Chr(AscW(MidB(binstr,i+1,1) & clow))
skipflag=1
Else
str = str & Chr(AscB(clow))
End If
Else
skipflag=0
End If
Next
Bin2Str = str
End Function
'*******************************************************************
' Function Name:SimpleBin2Str()
' Convert binstr to Unicode str Just for English words and Little words
'*******************************************************************
Function SimpleBin2Str(Binary)
Dim I, S
For I = 1 To LenB(Binary)
S = S & Chr(AscB(MidB(Binary, I, 1)))
Next
SimpleBin2Str = S
End Function
'*******************************************************************
' Function Name:BinaryToString()
' Convert binstr to Unicode str Just for English words and Little words
'*******************************************************************
Function BinaryToString(Binary)
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
BinaryToString = pl1 & pl2 & pl3
End Function
'BinaryToString方法比SimpleBinaryToString方法性能高20倍。建议用来处理2MB以下的数据。
'使用ADODB.Recordset
'ADODB.Recordset 可以让你支持几乎所有VARIANT支持的数据类型,你可以用它在string和binary之间转换。
Function RSBinaryToString(xBinary)
Dim Binary
If vartype(xBinary)=8 Then Binary = MultiByteToBinary(xBinary) Else Binary = xBinary
Dim RS, LBinary
Const adLongVarChar = 201
Set RS = CreateObject("ADODB.Recordset")
LBinary = LenB(Binary)
If LBinary>0 Then
RS.Fields.Append "mBinary", adLongVarChar, LBinary
RS.Open
RS.AddNew
RS("mBinary").AppendChunk Binary
RS.Update
RSBinaryToString = RS("mBinary")
Else
RSBinaryToString = ""
End If
End Function
Response.write "<textarea rows=25 cols=100>" & Bytes2Str(xmlReadUrl(URLEncoding("http://Localhost"))) & "</textarea>"
%>
- ASP+XMLHTTP取得网页代码
- 用XMLHTTP方式取得网页内容
- asp 利用 xmlhttp 抓取网页内容
- ASP利用XMLHTTP抓取网页内容
- ASP用xmlhttp获得网页源代码
- 利用xmlhttp获得网页代码的注意事项
- 使用XmlHttp结合ASP实现网页的异步调用
- 使用XmlHttp结合ASP实现网页的异步调用
- asp通过xmlhttp抓取网页内容不完整
- Asp.NET XMLHTTP获取网页内容C#版
- 将XMLHTTP组件写成类方便获取网页代码
- Asp.net取得页面执行时间的代码
- 常用网页代码/ASP代码
- xmlhttp获取网页源码
- [ASP.NET]Asp.net取得页面执行时间的代码
- [ASP代码]强制刷新网页
- asp.net关闭网页代码
- asp.net 关闭网页代码
- SQL SERVER的命令行工具Osql的用法
- 查看QQ在线的网页代码
- 形容长得丑的30句经典句子
- 中国十大恶心女歌手
- 大学经典笑话
- ASP+XMLHTTP取得网页代码
- 在C#应用程序与DLL交互中使用消息
- C#-第一个应用程序
- 利用C#重启远程计算机
- .NET架构的核心技术
- FTP批处理
- 七七情人节
- 用索引提高SQL Server性能
- VB与SQL Server实现文件上传下载