Google天气预报报告计算中的问题 [英] Problem on Google weather report calcuation

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

问题描述

这与 Google天气报告XML 有关.

Google在做什么?

What is the calculation Google is doing?

当我使用 weather = London,UK 关键字搜索Google时,它显示的是该屏幕截图,

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

替代文本http://img293.imageshack.us/img293/4746/weathergoogle .jpg

在我的XML中,没有类似26、11、26、22否

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

我的XML如下所示.

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

What is the calculation involved in the weather report?

如何将它们转换为PHP变量?

How to get these into PHP variable?

推荐答案

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

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

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

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

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

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提供了许多用于XML的库.最突出的是 DOM SimpleXML .请查看PHP手册中有关如何使用它们的示例.堆栈溢出也有许多有关其用法的问题和答案.

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.

更新后进行似乎Google会根据请求提要的浏览器中设置的语言,为您提供华氏温度的高/低值.将语言参数hl=[languagecode]添加到URL中,以查看是否可以在摄氏温度下进行请求;或者-如果无法执行此操作,则-

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天全站免登陆