PHP code example of balsama / coronadatascraperclient
1. Go to this page and download the library: Download balsama/coronadatascraperclient library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
balsama / coronadatascraperclient example snippets
$regionsBase = new Balsama\RegionsBase();
$regionsBase = new Balsama\RegionsBase();
// Get all regions:
$regions = $regionsBase->getRegions();
// Get a specific region:
$spain = $regionsBase->getRegion('ESP');
// Regions ties:
$westchesterCoNy = $regionsBase->getRegion('Westchester County/ NY/ USA');
$lafayetteParishLa = $regionsBase->getRegion('Lafayette Parish/ LA/ USA');
// Cities:
$quebec = $regionsBase->getRegion('Quebec/ CAN');
// Inspect the keys of the array of Region objects returned by $regionBase->getResgions for a complete list of regions.
$regionsBase = new Balsama\RegionsBase();
// Get all US States
$usStates = $regionsBase->getCountrysStates('USA');
$regionsBase = new Balsama\RegionsBase();
$spain = $regionsBase->getRegion('ESP');
// Basic information:
$spain->getName(); // The name of the region.
$spain->getType(); // The type, either country, state, county, or city.
$spain->getCountry(); // The country to which the region belongs.
$spain->getLatestCount(); // The latest count of cumulative positive test results.
$spain->getLatestDeaths(); // The latest count of cumulative deaths.
// US Counties have a FIPS number.
$lafayetteParishLa = $regionsBase->getRegion('Lafayette Parish/ LA/ USA');
$lafayetteParishLa->getFips(); // The FIPS code for the county.
// Sets of numbers:
// An array of all available positive cases counts keyed by the timestamp of the day of the count.
$spain->getCases();
// An array of all death count keyed by the timestamp of the day of the count.
$spain->getDeaths();
// An array of all discharged count data keyed by the timestamp of the day of the count.
$spain->getDischarged();
// An array of the percentage pf the population which has tested positive keyed by the day of the count.
$spain->getPercentages();
// `getPercentages()` takes an optional argument to get the same for deaths instead of cases.
$spain->getPercentages('deaths');
// An array of numbers representing the number of positive test cases per 100,000 people in the region. The $n argument
// strips values less than $n. So if you want to see the trajectory of a region once it has reached 10 in 100,000 cases
// you would pass `10` as $n.
$spain->getPer100kAboveN(10);
$regionsBase = new Balsama\RegionsBase();
$usStates = $regionsBase->getCountrysStates('ESP');
$usStatesPer100kAbove10 = [];
foreach ($usStates as $stateName => $state) {
$usStatesPer100kAbove10[$stateName] = $state->getPer100kAboveN(10);
}
// The `writeCsvTableFromData` method expects the data to be in an array keyed by the region.
Balsama\Utilities::writeCsvTableFromData($usStatesPer100kAbove10);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.