问一个问题:关于XmlHttp!!
但是有些空间显示不出来结果,有些可以!
不知道不显示结果的空间限制了什么功能,各位可以帮帮我吗?
可以显示结果的
http://asp.169163.net/user-371267/ShowNcWeather.asp
无法显示结果的:
http://www.tyemyl.com/qsh/ShowNcWeather.asp
源代码如下:
-----------------------------------------------
-----------------------------------------------
<%
'Server.ScriptTimeOut=3
dim temp1,temp2,temp3
call main("http://cn.weather.yahoo.com/CHXX/CHXX0097/index_c.html")
'主处理文件
function main(url)
on error resume next
if isNull(url) or url="0" then ShowError()
dim w1,w2,w3,w4,w5
'分别是今天天气,最高温度,最低温度,风向,风力
'取得网址
w1=getHTTPPage(url)
if w1 = "" or len(w1) < 500 then ShowError()
temp1=instr(w1,"<br><br><span class=sbody>")
temp2=instr(w1,"风力:</td><td class=sbody>")+35
if temp1=0 then showError()
temp1=temp1+26
'取出中间值
w2=mid(w1,temp1,temp2-temp1)
w1=mid(w1,temp1,20)
Temp3=instr(w1,"<")
if Temp3>0 then
w1=mid(w1,1,temp3-1)
end if
'开始取最高温度
Temp1=instr(w2,"最高:")
Temp2=instr(w2,"风力:</td><td class=sbody>")+35
if temp1=0 then showError()
temp1=temp1+36
w3=mid(w2,temp1,temp2-temp1)
w2=mid(w2,temp1,15)
Temp3=instr(w2,"<")
if Temp3>0 then
w2=mid(w2,1,temp3-1)
end if
'开始取最低温度
Temp1=instr(w3,"最低:")
Temp2=instr(w3,"风力:</td><td class=sbody>")+35
if Temp1=0 then showError()
Temp1=Temp1+36
W4=mid(w3,Temp1,Temp2-Temp1)
W3=mid(w3,Temp1,15)
Temp3=instr(W3,"<")
if Temp3>0 then
w3=mid(w3,1,Temp3-1)
end if
'开始取风向
Temp1=instr(w4,"风向:</td><td class=sbody>")
Temp2=instr(w4,"风力:</td><td class=sbody>")+35
if Temp1=0 then showError()
Temp1=Temp1+24
W5=mid(w4,Temp1,Temp2-Temp1)
w4=mid(w4,Temp1,30)
Temp3=instr(w4,"<")
if Temp3>0 then
w4=mid(w4,1,temp3-1)
end if
'开始取风力
Temp1=instr(w5,"风力:</td><td class=sbody>")
if Temp1=0 then showError()
Temp1=Temp1+24
w5=mid(w5,Temp1,30)
Temp3=instr(w5,"<")
if Temp3>0 then
W5=mid(w5,1,Temp3-1)
end if
response.write(w1&",最高温度:"&w2&",最低温度:"&w3&",风向:"&w4&", 风力:"&w5)
end function
'取得网页文件代码函数
function getHTTPPage(url)
dim http
set http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function
'字节转化成字符串函数
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
'错误提示函数
function ShowError()
Response.write "很抱歉:因系统错误,无法通知天气情况!今天天气情况请访问 <a href=""http://cn.weather.yahoo.com/CHXX/CHXX0097/index_c.html"" target=_blank>这里</a>"
Response.end
end Function %>
相关推荐
XMLHTTP中setRequestHeader参数问题
ajax 请求头部设置 XMLHTTP中setRequestHeader参数问题
Excel vba使用XMLHTTP进行异步下载的演示
大文件下载不再卡机。XMLHTTP的OnReadyStateChange事件进行异步下载的演示。例子是下载一个8M的mp3文件
VFP xmlHTTP应用实例
VFP xmlHTTP应用实例,搭建API,三层结构 内附测试环境及asp代码
用XMLHTTP很好的一个例子
进入www.ting88.com的网站,把歌手专辑页面的URL复制到文本框中再提交就可以得到歌曲的下载路径,如:http://www.ting88.com/MusicList/4141.htm 源程序如下: <% on error resume next dim id,url,getCode,m,i,j,s,d,ns,nd,num,name id=trim(request.querystring(“id”)) ‘1.获取原网页所有内容 Function getHTTPPage(url) dim http set http=Server.createobject(“Micros
php_xmlhttp 乱码问题解决方法
resin在新版本中竟开始支持php了,偶感觉比较好玩,也是懒得在自己机器上再配置一组apache_php_mysql之流,毕竟以java为主做事情的嘛。于是将自己的一个php站点直接放resin里面做开发了,总体感觉还不错,基本功能没发现问题,但在继续优化过程中,想到了xmlhttp,便随手写了几个文件试一下,无刷新效果嘛,可是竟然遇到了中文乱码,于是五一一天就折腾这个了,也在中间从网站看了一些当前地球上的一些争争吵吵的事情,中美对弈,欧则看盘,一会儿顺着这边说,一会顺着那边扯,也有些意思,只是想,中国的80末以后的这些人会长成什么样子,靠吃6、70年代人赚下的本活着,还以享乐为荣,关键是还



