码迷,mamicode.com
首页 > Web开发 > 详细

asp发送http请求,获取一个url的内容

时间:2014-11-12 21:23:08      阅读:431      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   color   ar   os   sp   div   on   

response.Write("http://"&Request.ServerVariables("HTTP_HOST")&"/jfclear"&Request.ServerVariables("REQUEST_URI"))

Response.Write(GetHttpPage("http://www.baidu.com/","UTF-8"))


Function GetHttpPage(url, charset) 
    Dim http 
    Set http = Server.createobject("Msxml2.ServerXMLHTTP")
    http.Open "GET", url, false
    http.Send() 
    If http.readystate<>4 Then
        Exit Function 
    End If 
    GetHttpPage = BytesToStr(http.ResponseBody, charset)
    Set http = Nothing
End function


Function BytesToStr(body, charset)
    Dim objStream
    Set objStream = Server.CreateObject("Adodb.Stream")
    objStream.Type = 1
    objStream.Mode = 3
    objStream.Open
    objStream.Write body
    objStream.Position = 0
    objStream.Type = 2
    objStream.Charset = charset
    BytesToStr = objStream.ReadText 
    objStream.Close
    Set objStream = Nothing
End Function

asp发送http请求,获取一个url的内容

标签:style   http   io   color   ar   os   sp   div   on   

原文地址:http://my.oschina.net/u/937746/blog/343689

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!