用XMLHTTP生成静态页面...为什么本地可以用,但是一放到网上就不行?
Function getHTTPPage(url)
On Error Resume Next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then'判断文档是否已经解析完,以做客户端接受返回消息
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")'返回信息,同时用函数定义编码
set http=nothing
If Err.number<>0 then
Response.Write "<p align='center'><font color='red'><b>服务器获取文件内容出错</b></font></p>"
Err.Clear
End If
End function
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 = "GB2312"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
dim rs,fso,fout,gycode,city,scode,rcode,Url,Html
response.write "<p align=center><font color=blue>正在操作,请耐心等待,不要退出!</font><br><br>"
city=split(request("buyregion"),",")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
j=0
for i=0 to ubound(city)
Url = "http://www.2112112.com/1.asp?cityname=3301"
Html = getHTTPPage(Url)
' response.write(Html)
Set foutr = fso.CreateTextFile(server.mappath("../3301.htm"))
foutr.WriteLine Html
foutr.close
-----------------------------------------
为什么本地可以用,但是一放到网上就不行?
不知道怎么回事???????WHY?