PHP code example of vkarchevskyi / sinoptik.ua-parser

1. Go to this page and download the library: Download vkarchevskyi/sinoptik.ua-parser 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/ */

    

vkarchevskyi / sinoptik.ua-parser example snippets


$data = new ScraperFactory()
    ->make()
    ->getCurrentTimeData()

echo json_encode($data);

$data = new ScraperFactory()
    ->setCity('Lviv')
    ->setDate(new DateTimeImmutable('+3 days'))
    ->setTimezone('Europe/Kyiv')
    ->make()
    ->getData()

echo json_encode($data);
json
[
  {
    "time": "3:00",
    "data": {
      "description": "Невеликі високі хмари",
      "temperature": "-3",
      "feelsLike": "-3",
      "pressure": "741",
      "humidity": "85",
      "wind": "1.3",
      "precipitationProbability": "17"
    }
  },
  {
    "time": "9:00",
    "data": {
      "description": "Хмарно з проясненнями",
      "temperature": "0",
      "feelsLike": "-3",
      "pressure": "740",
      "humidity": "84",
      "wind": "2",
      "precipitationProbability": "58"
    }
  },
  {
    "time": "15:00",
    "data": {
      "description": "Суцільна хмарність",
      "temperature": "+4",
      "feelsLike": "+1",
      "pressure": "740",
      "humidity": "55",
      "wind": "4.3",
      "precipitationProbability": "76"
    }
  },
  {
    "time": "21:00",
    "data": {
      "description": "Невелика хмарність",
      "temperature": "+1",
      "feelsLike": "-1",
      "pressure": "742",
      "humidity": "57",
      "wind": "1.7",
      "precipitationProbability": "47"
    }
  }
]