Download the PHP package office360/weather-crawler without Composer

On this page you can find all versions of the php package office360/weather-crawler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package weather-crawler

office360/weather-crawler

一个PHP天气数据获取工具,用于学习和研究目的获取天气相关信息。

重要声明

⚠️ 法律风险提示

  1. 本工具仅供学习和研究使用,不得用于任何商业用途。
  2. 本工具获取的天气数据来源于第三方网站,数据版权归原网站所有。
  3. 使用本工具时,请严格遵守相关网站的使用条款、robots协议以及中国法律法规。
  4. 本工具不保证数据的准确性、完整性和时效性,使用数据时请自行验证。
  5. 使用者应自行承担因使用本工具而产生的所有法律责任和风险。
  6. 请勿使用本工具进行过于频繁的请求,以免对目标网站造成不必要的负担。

免责声明

本工具的开发和发布仅出于技术研究和学习目的。对于因使用本工具而导致的任何直接或间接损失,包括但不限于数据丢失、系统损坏、法律纠纷等,作者不承担任何责任。

使用者应在遵守相关法律法规的前提下使用本工具,并自行评估和承担所有风险。

功能特性

安装

方法一:使用Composer安装(推荐)

方法二:从GitHub仓库安装开发版本

如果遇到网络问题,可以在composer.json中手动添加仓库配置:

然后运行:

快速开始

创建一个简单的PHP文件来测试天气爬虫:

使用流式接口获取天气数据(推荐)

通过城市名称获取天气数据

通过经纬度获取天气数据

通过IP地址获取天气数据

运行上面的代码,您将看到对应城市的天气数据。

使用方法

基本用法(自动定位)

根据城市代码直接获取天气数据

根据城市名称获取天气数据

手动指定IP地址获取天气数据

获取综合天气数据

API参考

WeatherCrawler类

工厂方法

create()

创建WeatherCrawler实例的静态工厂方法。

返回值:

流式接口方法

forCity(string $cityName)

通过城市名称设置城市代码。

参数:

返回值:

forCoordinates(float $latitude, float $longitude)

通过经纬度坐标设置城市代码。

参数:

返回值:

forIp(?string $clientIp)

通过IP地址设置城市代码。

参数:

返回值:

forCurrentLocation()

通过当前访问者IP地址自动设置城市代码。

返回值:

forCityCode(string $cityCode)

直接设置城市代码。

参数:

返回值:

getWeather(string $type = 'comprehensive', int $hourlyLimit = 24)

获取指定类型的天气数据。

参数:

返回值:

获取城市ID的方法

getCityCodeByName(string $cityName)

通过城市名称获取城市代码。

参数:

返回值:

getCityCodeByCoordinates(float $latitude, float $longitude)

通过经纬度坐标获取城市代码。

参数:

返回值:

getCityCodeByIp(?string $clientIp)

通过IP地址获取城市代码。

参数:

返回值:

getVisitorData(?string $clientIp)

获取访客的IP、所在城市、区域等信息。

参数:

返回值:

获取天气数据的方法

getCurrentWeather(string $cityCode)

获取当前天气数据(包含基础和详细数据)。

参数:

返回值:

get7DayWeather(string $cityCode)

获取7日天气预报。

参数:

返回值:

get15DayWeather(string $cityCode)

获取15日天气预报。

参数:

返回值:

getHourlyWeather(string $cityCode, int $limit = 24)

获取逐小时天气预报。

参数:

返回值:

getAllWeather(string $cityCode)

获取综合天气数据,包含当前天气、15日预报和逐小时预报。

参数:

返回值:

getCityCodeMap()

获取城市代码映射表。

返回值:

注意事项

  1. 本工具依赖于第三方数据源的结构和接口,若数据源结构发生变化,可能导致数据获取失败。
  2. 使用前请务必阅读并遵守相关数据源的使用条款、robots协议以及中国法律法规。
  3. 合理控制请求频率,避免对数据源造成不必要的负担,建议在生产环境中添加缓存机制。
  4. 本工具获取的数据仅供参考,请勿用于任何关键决策或商业用途。
  5. 请确保您的使用行为符合相关法律法规,包括但不限于《中华人民共和国网络安全法》、《中华人民共和国著作权法》等。
  6. 若您不确定使用本工具是否合法,请咨询专业法律意见

开发

运行测试

许可证

MIT License


All versions of weather-crawler with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package office360/weather-crawler contains the following files

Loading the files please wait ...