利用ResponseXML的方法调用163天气预报
网络 2009/1/23 9:46:38 深山行者 字体:
大 中 小 浏览 14038
以下是引用片段:
<!-- 以下是抓取的XML源,http://www.163.com/weatherxml/58044.xml
<?xml version="1.0" encoding="GBK"?> <root> <weather c="连云港" city="58044" qx="阴转晴" wd="-7℃~-2℃" fl="6~7级" qximg="02.gif,00.gif" lk="1级 干燥 晴天,虽然天气有点凉,但其它条件适宜,路面比较干燥,路况较好。 "/> </root> --> <% url = "http://www.163.com/weatherxml/58044.xml" ' 58044 是连云港相对应的天气预报码 Set http=Server.CreateObject("Microsoft.XMLHTTP") http.Open "GET",url,False http.send Set xml=Server.CreateObject("Microsoft.XMLDOM") xml.Async=true xml.ValidateOnParse=False xml.Load(http.ResponseXML) If xml.ReadyState>2 Then Response.Write("文档已经准备就绪。状态:"& xml.ReadyState &"<br>") '这句可不加 set res = xml.selectSingleNode("http://weather") Response.Write res.getAttribute("c") Response.Write " " Response.Write res.getAttribute("wd") Response.Write " " Response.Write res.getAttribute("qx") Response.Write " " Response.Write res.getAttribute("fl") Response.Write " " tqimg = split(res.getAttribute("qximg"),",") '以下为显示天气小图标 if tqimg(0) <> "" then Response.Write "<img src='http://news.163.com/img/logo/"& tqimg(0) &"'>" elseif tqimg(1) <> "" then Response.Write "<img src='http://news.163.com/img/logo/"& tqimg(1) &"'>" else response.Write "" end if Response.Write "<br>" End if
Set oNode = Nothing Set oDoc = Nothing %>
|
- 相关阅读
- asp获得当前文件的虚拟物理路径
- python通过代码修改pip下载源让下载库飞起
- 网站内容中某个关键字相关右键菜单
- 非常不错的页面搜索器,还可以移动
- 获得当前页面的长宽高各项参数
- 阿里云短信验证码签名不合法isv.SMS_SIGNATURE_ILLEGAL
- 有利于搜索引擎的一些常用的CSS命名规则
- 商业版增加线路日期报价功能样式选择(增加了3个日期报价效果)
- 共有0条关于《利用ResponseXML的方法调用163天气预报》的评论
- 发表评论