This commit is contained in:
salam committed 2026-09-26 18:22:30 +02:00
1 parent 8325f3a334
commit 5188d1f171
2 files changed
+9 -61

No files matched your search

@@ -1,61 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Sofascore\Helper;
use App\Console\Commands\Grap;
use App\Utilities\Notice;
// use ForceUTF8\Encoding;
class CurlLivescore
{
public static function load(string $url)
{
$debug = Grap::$options['d'] ?? 0;
if ($debug) {
Notice::note($url, 'b');
}
$useragents = [];
$useragents[1] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15';
$useragents[2] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15';
$useragents[3] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
$useragents[4] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15';
$useragents[5] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0';
$useragents[6] = 'Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36';
$headers = [
'GET /horse-racing/canada/woodbine-2020/ HTTP/1.1',
'Host: www.livescore.in',
'User-Agent: '.$useragents[Grap::$useragent],
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language: de,en-US;q=0.9,en;q=0.8',
'Accept-Encoding: gzip, deflate, br, zstd',
'Referer: https://www.livescore.in/horse-racing/canada/woodbine/archive/',
'Upgrade-Insecure-Requests: 1',
'Sec-Fetch-Dest: document',
'Sec-Fetch-Mode: navigate',
'Sec-Fetch-Site: same-origin',
'Sec-Fetch-User: ?1',
'Connection: keep-alive',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_ENCODING, '');
$data = curl_exec($ch);
// $data = Encoding::toUTF8($data);
// $data = gzdecode($data);
// $data = json_decode($data, true);
return $data;
}
}
+9
View File
@@ -384,4 +384,13 @@ trait GrappingHelper
return $results;
}
protected function clean_string(string $string)
{
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
$string = strtolower($string);
return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
}
}