ovidigital / covid-19-data-scraper
此包已被弃用且不再维护。没有建议的替代包。
PHP库,用于从互联网上的多个来源提取COVID-19统计数据
1.2.0
2020-04-26 16:01 UTC
Requires
- php: ^7.2
- ext-json: *
- league/iso3166: ^2.1
- ovidigital/js-object-to-json: ^1.0
- symfony/css-selector: ^5.0
- symfony/dom-crawler: ^5.0
- symfony/http-client: ^5.0
Requires (Dev)
- kint-php/kint: ^3.3
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2021-11-27 00:18:57 UTC
README
PHP库,用于从多个来源提取COVID-19统计数据
此库旨在提供一种快速提取互联网上多个来源的COVID-19(新型冠状病毒肺炎2019)统计数据的方法,并以多种格式(PHP数组、JSON、CSV等)提供这些数据。
免责声明
本软件仅供教育和演示目的。
使用此软件,您可能需要从各自的拥有者那里获得事先许可才能访问资源(例如Worldometers冠状病毒)。
在使用此软件访问此类资源之前,确保已获得适当的许可,是此软件用户的唯一责任。
许可
本项目采用MIT许可协议。
请查阅LICENSE.md文件了解许可权利和限制。
安装
composer require ovidigital/covid-19-data-scraper
用法
use OviDigital\Covid19DataScraper\StatisticsService; $statisticsService = new StatisticsService(); // Scrape Worldometers aggregated statistics for all countries $dataObject = $statisticsService->getWorldometersAggregated(); // Scrape Worldometers aggregated statistics for specific countries using alpha-2 country codes $dataObject = $statisticsService->getWorldometersAggregated(['US', 'RO']); // Scrape Worldometers country statistics for specific country (e.g. Romania) $dataObject = $statisticsService->getWorldometersCountry('RO'); // Get data as PHP array $dataAsArray = $dataObject->toArray(); // Get data in JSON format $dataAsJson = $dataObject->toJson();
返回数据
根据用于抓取统计数据的来源,数据和模式可能会有所不同。
以下示例显示部分示例数据。
示例Worldometers聚合数据
{ "meta": { "timestamp": 1587914124 }, "countries": { "US": { "meta": { "country_code": "US", "country_name": "United States of America", "country_slug": "us" }, "data": { "total_cases": 123456, "new_cases_today": 1337, "total_deaths": 45678, "new_deaths_today": 101, "total_recovered": 80000, "total_active_cases": 765432, "total_serious_critical": 13337, "total_tests": 4194304, "cases_per_million": 2121, "deaths_per_million": 196, "tests_per_million": 16384 } }, "RO": { "meta": { "country_code": "RO", "country_name": "Romania", "country_slug": "romania" }, "data": { "total_cases": 10123, "new_cases_today": 321, "total_deaths": 500, "new_deaths_today": -5, "total_recovered": 2350, "total_active_cases": 7123, "total_serious_critical": 210, "total_tests": 112112, "cases_per_million": 543, "deaths_per_million": 25.15, "tests_per_million": 12345 } } } }
示例Worldometers国家数据
{ "meta": { "timestamp": 1587901089, "country_code": "RO", "country_name": "Romania" }, "data": { "totals": { "cases": 1500, "deaths": 60, "recovered": 120 }, "daily": { "new_cases": { "2020-02-15": "null", "2020-02-16": "null", "2020-02-17": 100, "2020-02-18": 200, "2020-02-19": 300, "2020-02-20": 400, "2020-02-21": 500 }, "new_deaths": { "2020-02-15": 0, "2020-02-16": 0, "2020-02-17": 0, "2020-02-18": 0, "2020-02-19": 10, "2020-02-20": 20, "2020-02-21": 30 }, "new_recovered": { "2020-02-15": 0, "2020-02-16": 0, "2020-02-17": 0, "2020-02-18": 0, "2020-02-19": 20, "2020-02-20": 40, "2020-02-21": 60 }, "total_active_cases": { "2020-02-15": "null", "2020-02-16": "null", "2020-02-17": 100, "2020-02-18": 300, "2020-02-19": 570, "2020-02-20": 910, "2020-02-21": 1320 }, "total_deaths": { "2020-02-15": 0, "2020-02-16": 0, "2020-02-17": 0, "2020-02-18": 0, "2020-02-19": 10, "2020-02-20": 30, "2020-02-21": 60 } } } }
贡献
请随时提交拉取请求或创建一个问题。