Google API 获取天气预报信息

本文介绍了如何通过Google API 获取天气预报信息,并提供了详细的XML封装天气信息解析示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://www.chncms.com/2010/08/30/GOOGLEAPIWEATHER.html


要获得天气预报信息可用利用Google提供的借口,

http://www.google.com/ig/api?hl=zh_cn&weather=城市名称(拼音)

它将返回一个用xml封装的天气信息。

示例:
http://www.google.com/ig/api?hl=zh_cn&weather=shanghai

返回:

<?xml version="1.0"?>

- < xml_api_reply version =" 1 " >
- < weather module_id =" 0 " tab_id =" 0 " mobile_row =" 0 " mobile_zipped =" 1 " row =" 0 " section =" 0 " >
- < forecast_information >
< city data =" Shanghai, Shanghai " />
< postal_code data =" shanghai " />
< latitude_e6 data =" " />
< longitude_e6 data =" " />
< forecast_date data =" 2010-08-30 " />
< current_date_time data =" 2010-08-30 17:00:00 +0000 " />
< unit_system data =" SI " />
</ forecast_information >
- < current_conditions >
< condition data =" 多云 " />
< temp_f data =" 84 " />
< temp_c data =" 29 " />
< humidity data =" 湿度: 62% " />
< icon data =" /ig/images/weather/cn_cloudy.gif " />
< wind_condition data =" 风向: 东北、风速:7 米/秒 " />
</ current_conditions >
- < forecast_conditions >
< day_of_week data =" 周一 " />
< low data =" 27 " />
< high data =" 33 " />
< icon data =" /ig/images/weather/chance_of_rain.gif " />
< condition data =" 可能有雨 " />
</ forecast_conditions >
- < forecast_conditions >
< day_of_week data =" 周二 " />
< low data =" 26 " />
< high data =" 34 " />
< icon data =" /ig/images/weather/chance_of_storm.gif " />
< condition data =" 可能有暴风雨 " />
</ forecast_conditions >
- < forecast_conditions >
< day_of_week data =" 周三 " />
< low data =" 26 " />
< high data =" 33 " />
< icon data =" /ig/images/weather/chance_of_storm.gif " />
< condition data =" 可能有暴风雨 " />
</ forecast_conditions >
- < forecast_conditions >
< day_of_week data =" 周四 " />
< low data =" 26 " />
< high data =" 34 " />
< icon data =" /ig/images/weather/chance_of_rain.gif " />
< condition data =" 可能有雨 " />
</ forecast_conditions >
</ weather >
</ xml_api_reply >

转载请注明:来自ChnCMS
本文地址:http://www.chncms.com/2010/08/30/GOOGLEAPIWEATHER.html



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值