利用google天气api获取最近的天气

来源:互联网 发布:关于借钱的网络段子 编辑:程序博客网 时间:2024/04/29 14:18
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
</head>
<body>
<%
 weather = "http://www.google.com/"
 dim URL,xml,xmlDom,oItem,Link,title,DateAndTime,nContent
 URL="http://www.google.com/ig/api?hl=zh-cn&weather=Seoul"
 'Microsoft.XMLHTTP对象,能够完成从数据包到Request对象的转换以及发送任务
 Set xml = Server.CreateObject("Microsoft.XMLHTTP")
 xml.Open "GET", URL, False
 xml.Send
 '利用microsoft.xmldom对象对获取到的XML对象进行分析。
 Set xmlDom = server.createObject("microsoft.xmldom")
 xmlDom.async=False
 xmlDom.ValidateOnParse=false
 xmlDom.load(xml.responseXML)
 'Response.Write(xmlDom.ReadyState)
 if xmlDom.ReadyState>2 Then
 
 Set oItem=xmlDom.getElementsByTagName("forecast_conditions")
 
 For i=0 to 2
  low_data = oItem(i).childNodes(1).Attributes.item(0).Text
  high_data = oItem(i).childNodes(2).Attributes.item(0).Text
  icon_data = weather&oItem(i).childNodes(3).Attributes.item(0).Text
  condition = oItem(i).childNodes(4).Attributes.item(0).Text
 
  Select Case i  
   Case "0"
    showday = "今天"
   Case "1"
    showday = "明天"
   Case "2"
    showday = "后天"  
  End Select
%>
<div class="wea1">
  <table width="63" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" class="title3"><%=showday%></td>
    </tr>
    <tr>
      <td height="40" align="center"><img src="<%=icon_data%>" width="40" height="40" alt="<%=condition%>"></td>
    </tr>
    <tr>
      <td height="20" align="center"><%Response.Write(low_data&"~"& high_data &"℃")%></td>
    </tr>
    <tr>
      <td height="20" align="center"><%=condition%></td>
    </tr>
  </table>
</div>
<%
 Next
 End If
%>
</body>
</html>
原创粉丝点击