<% If request("mobile")<>"" Then %><%
'转换为字符串函数
Function BytesToBstr(body,Cset)
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
'提交手机号到http://www.ip138.com:8080/search.php,并得到查询的地址
Function returnIPAddress(mobile)
dim xmlHttp
set xmlHttp=server.createobject("MSXML2.XMLHTTP")
str = "mobile="&mobile&"&action=mobile" 'str为POST的数据,既要查询的表单的内容提交。
xmlHttp.open "POST","http://www.ip138.com:8080/search.php",false
xmlHttp.setRequestHeader"Content-Length",Len(str)
xmlHttp.setRequestHeader"CONTENT-TYPE","application/x-www-form-urlencoded"
xmlHttp.send(str)
tempstr=BytesToBstr(xmlHttp.responseBody,"GB2312") '使用responseBody方法获取返回值
session("tempstr")=tempstr
End Function
'取得访问用户的手机
visitormobile = request("mobile")
response.write(returnIPAddress(visitormobile))
Str=session("tempstr")
a=" "
b=" "
arr=split(replace(str,a,b),b)
'Response.Write replace(str,a,b)&" "
For i = 0 To UBound(arr)
if i=1 then
c=replace(replace(arr(i),"""",""),"更详细的..","")
d=replace(c,"","")
e=replace(d,"++ ip138.com查询结果 ++","阿里查询的手机号码查询结果")
f=replace(e," ","")
g=replace(f," | ","")
Response.Write g&" |