johnnymck/shippingforecast

航运预报抓取库,从BBC航运预报页面获取数据。基于tnm/shipping-forecast

0.1.2 2019-11-17 21:00 UTC

This package is auto-updated.

Last update: 2024-09-14 02:12:54 UTC


README

这是一个简单的PHP编写的航运预报API,从BBC航运预报网页抓取最新信息。

源代码基于Ted Nyman的航运预报项目。向那个人表示最大的敬意! :)

安装

composer install johnnymck/shippingforecast

使用

use ShippingForecast\ShippingForecast;

$forecast = new ShippingForecast();
$cromarty = $forecast->get('Cromarty'); // location names must be capitalised

echo $cromarty['time']; // eg,  'The general synopsis at 1800'...
print_r($cromarty['content']['warning']); // returns array of warnings (often empty, though not in wintertime 😅)
echo $cromarty['content']['visibility']; // eg, 'Good, occasionally poor'...

值得注意的是,ShippingForecast::get($foo)ShippingForecast::getAll()都会返回一个包含['time']的关联数组,这是BBC最后一次更新的时间字符串,以及包含预报信息的['content'],其中还包括一个['warning']数组以提供任何普遍的警告信息。参见examples/以获取更多信息。

有趣的事情!

在应用程序的根目录下运行php readforecast.php并将输出重定向到语音合成应用程序(例如Macintosh上的say),可以读取最新的预报更新,而无需每天调整您的无线设备到BBC R4,三次一天。这是多么美好的时代啊!

./forecast [大写区域名称]将在您指定的区域内返回文本格式的预报