您所在的位置:小祥子 » 编程 » ASP » 正文

ASP模拟POST提交数据并返回内容

时间:2015-02-18 编辑:本站 来源:本站原创

两个函数,一个是模拟POST数据的函数,一个是转换编码的函数(之前已经介绍过)。

Function GetBody(ips) '获取远程IP地址POST信息
Set https = Server.CreateObject("MSXML2.XMLHTTP")
With https
.Open "Post", "http://www.ip138.com/ips8.ASP", False
.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
.Send "ip="&ips&"&action=2"
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody,"GB2312")
Set https = Nothing
End Function
 
 Function BytesToBstr(body,Cset) '转换GB2312
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 = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
 
 Response.Write GetBody("61.186.177.105")