使用经典ASP

时间:2019-12-23 15:55:57

标签: asp-classic

是否可以读取另一个页面的元素并获取整个HTML代码?

例如,我想从此页面获取所有HTML:http://localhost/test3.html

谢谢!

1 个答案:

答案 0 :(得分:0)

这是我使用的功能:

function http_post (strUrl, data)
    ' call another URL (e.g. ASP or PHP script) via HTTP and POST. "data" should be GET-style parameter string or empty '
    dim xmlHttp
    Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP.6.0")
    With xmlHttp
        .Open "POST", strUrl, False
        .setRequestHeader "User-Agent", Request.ServerVariables("HTTP_USER_AGENT")
        .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        .setRequestHeader "Content-Length", Len(data)
        .Send data
        if .Status < 400 then
            http_post = .responseText
        else
            ' do error logging here if you want '
            http_post = false
        end if
        .abort()
    End With
    set xmlHttp = Nothing
end function