ASP Simulation method of post submitting data
Author:flymorn Source: Floating Easily
Categories:asp Programming posttime:2009-4-7 13:21:40
are
article:
Sometimes need to obtain some information on the remote Web site, and the server restricted get way, can only be submitted through post data, this time we can through the ASP to implement the simulation of the post data, drifting easy to process the following part of the code, such as to obtain IP138 IP data address information, code as follows: <%
On Error Resume Next ' fault-tolerant processing
Function getbody (IPs) ' Drift-get remote IP address post information
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) ' Drift easy: conversion 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")
%>