当前位置:编程学习 > asp >>

asp采集函数

答案:

' getHttpPage(xUrl,Charset)
' 采集函数
'
' #####################################################
'
' 该函数需要 Microsoft.XMLHTTP 组件支持
'
' xUrl 为要采集信息的地址
' Charset 为要采集的编码
'
' #####################################################
'
' a = BIN2STR(BinaryDate,"GB2312")
' a = BIN2STR(BinaryDate,"UTF-8")

Function getHttpPage(xUrl,Charset)
    On Error Resume Next
    Dim Http
    Set Http = Server.CreateObject("Microsoft.XMLHTTP")
    Http.Open "GET",xUrl,False
    Http.Send()
    If Http.ReadyState <> 4 Then
        Response.Write "无法连接采集源"
        getHttpPage = False
        Exit Function
    End If
    getHttpPage = BIN2STR(Http.responseBody,Charset)
    Set Http = Nothing
    If Err Then
        Response.Write "<p align='center'><font color='red'><b>服务器获取文件内容出错,请刷新重试!</b></font></p>"
        getHttpPage = Err.description
        Err.Clear
    End If 
End function

上一个:asp32 位十六进制数字字符串转 IP 地址
下一个:获取当前页面文件名

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,