Google天气报告计算出现问题 [英] Problem on Google weather report calcuation

查看:183
本文介绍了Google天气报告计算出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于 Google Weather Report XML



谷歌正在计算什么?



当我在 weather = London,UK 关键字,它显示了类似此屏幕截图的内容,



alt text http://img293.imageshack.us/img293/4746/weathergoogle.jpg

在我的XML中有没有像26,11,26,22没有



我的XML看起来像下面这样。

http://img171.imageshack.us/img171/7408/weatherxml.jpg =nofollow noreferrer>替代文字http://img171.imageshack.us/img171/7408/weatherxml.jpg



天气报告中涉及的计算是什么?



如何将这些数据导入PHP变量?

解决方案

没有计算。您链接的XML具有以下节点:

 < temp_f data =70/> 
< temp_c data =21/>

 <低数据=11/> 
< high data =26/>

前两个是当前天气的摄氏温度和华氏温度,对应于左手部分在Google Seach页面上。 Google搜索页面显示的预测值(仅限摄氏度)为高和低。



PHP提供了许多用于处理XML的库。最显着的是 DOM XMLReader and SimpleXML 。查看PHP手册中有关如何使用它们的示例。 Stack Overflow在使用方面也有许多问题和答案。




更新后的编辑:看起来像谷歌给你的高/华氏温度值较低,具体取决于请求馈送的浏览器中设置的语言。或者将语言参数 hl = [语言代码] 添加到URL中,以查看您是否可以以摄氏度请求该内容,或者 - 如果这不可行 - 手工转换高/低

 <$ c华氏度至华氏温度
摄氏度[°C] =([°F] - 32)×5/9 [°F] = [°C]×9/5 + 32


This is about the Google Weather Report XML.

What is the calculation Google is doing?

When I google with weather=London,UK keyword, it's showing something like this screen shot,

alt text http://img293.imageshack.us/img293/4746/weathergoogle.jpg

In my XML there is nothing like 26, 11, 26, 22 no

My XML look like below.

alt text http://img171.imageshack.us/img171/7408/weatherxml.jpg

What is the calculation involved in the weather report?

How to get these into PHP variable?

解决方案

There is no calculation. The XML you linked has these nodes:

<temp_f data="70"/>
<temp_c data="21"/>

and

<low data="11"/>
<high data="26"/>

The first two are the temperature in Celsius and Fahrenheit for the current weather and corresponds to the left hand part on the Google Seach page. High and Low is what the Google Search Page shows for the Forecast (Celsius only).

PHP provides a number of libraries for working with XML. The most prominent being DOM, XMLReader and SimpleXML. Have a look at the examples in the PHP Manual on how to use them. Stack Overflow also has numerous questions and answers regarding their usage.


EDIT after Update: Seems like Google gives you the high/low values in Fahrenheit depending on the language set in the browser requesting the feed. Either add the language param hl=[languagecode] to the URL to see if you can request this in Celsius or - if that's not possible - convert high/low by hand:

            from Fahrenheit               to Fahrenheit
Celsius     [°C] = ([°F] − 32) × 5⁄9      [°F] = [°C] × 9⁄5 + 32

这篇关于Google天气报告计算出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆