ConsultancyProject1_Auslast.../scraper/app/Scraper/Basic.php

36 lines
544 B
PHP

<?php
namespace App\Scraper;
use App\Models\Seed;
class Basic{
public function parseJSON($json){
return json_decode($json, 1);
}
public function get($url, bool $isJSON = true){
$ch = curl_init();
$options = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_FOLLOWLOCATION => true,
);
curl_setopt_array($ch, $options);
$request = curl_exec($ch);
curl_close($ch);
if($isJSON){
$request = $this->parseJSON($request);
}
return $request;
}
}