div にウォーター ディスプレイを表示する必要がある新しい Web サイトがあります。
表示したい:
- 地名
- cまたはfのウィーター
- アイコン
- アイコンの意味のテキスト
カナダ (ケベック州) から天気情報を取得する必要があります。
気象データの最新ストリームはどこで、どのように入手できますか?
Forget yahoo, the most easy and fast way to do that is with google weather API, you didnt specify what programing skill you have, so i will asume you know php and html, here is your code:
<?
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=jakarta');
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");
?>
<html>
<head>
<title>Google Weather API</title>
</head>
<body>
<h1><?= print $information[0]->city['data']; ?></h1>
<h2>Today's weather</h2>
<div class="weather">
<img src="<?= 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather"?>
<span class="condition">
<?= $current[0]->temp_f['data'] ?>° F,
<?= $current[0]->condition['data'] ?>
</span>
</div>
<h2>Forecast</h2>
<? foreach ($forecast_list as $forecast) : ?>
<div class="weather">
<img src="<?= 'http://www.google.com' . $forecast->icon['data']?>" alt="weather"?>
<div><?= $forecast->day_of_week['data']; ?></div>
<span class="condition">
<?= $forecast->low['data'] ?>° F - <?= $forecast->high['data'] ?>° F,
<?= $forecast->condition['data'] ?>
</span>
</div>
<? endforeach ?>
</body>
</html>
Good luck!
Yahoo にはフィード (JSON ではなく RSS) がありますが、常に最新の状態で、非常に簡単に使用できます。詳細については、次を参照してください。
これも良い応答/回答です: PHPでWeatherbugからの気象データを解析します