kullanici62 adlı üyeden alıntı: mesajı görüntüle
selamlar herkese,
arkadaşlar post kısmında bir sorun mu var gözden geçirebilir misiniz? sonuçları getirmiyor direk sorgu sayfasını gösteriyor. yani verileri post etmemiş gibi.

$fileme=file_get_contents('https://www.turkiye.gov.tr/saglik-titck-nobetci-eczane-sorgulama?submit');
$cookies = array();
foreach ($http_response_header as $hdr) {
    if (preg_match('/^Set-Cookie:\s*([^;]+)/', $hdr, $matches)) {
        parse_str($matches[1], $tmp);
        $cookies += $tmp;
    }
}

preg_match('#<input type="hidden" name="token" value="\{(.*?)\}" />#si', $fileme, $token);

$cityCode = 34;
$date = '19/09/2024';

function postByScrapedData($cityCode, $date, $cookies, $token){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.turkiye.gov.tr/saglik-titck-nobetci-eczane-sorgulama?submit',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 ,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => http_build_query ([
                'plakaKodu' => $cityCode,
                'nobetTarihi' => $date,
                'token' => $token,
                'btn' => 'Sorgula'
            ]),
            CURLOPT_HTTPHEADER => array(
                'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0',
                'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
                'Accept-Language: en-US,tr;q=0.5',
                'Accept-Encoding: gzip, deflate, br',
                'Referer: https://www.turkiye.gov.tr/saglik-titck-nobetci-eczane-sorgulama',
                'Content-Type: application/x-www-form-urlencoded',
                'Origin: https://www.turkiye.gov.tr',
                'Connection: keep-alive',
                'Cookie: '.http_build_query($cookies,'','; '),
                'Upgrade-Insecure-Requests: 1',
                'Sec-Fetch-Dest: document',
                'Sec-Fetch-Mode: navigate',
                'Sec-Fetch-Site: same-origin',
                'Sec-Fetch-User: ?1',
                'Pragma: no-cache',
                'Cache-Control: no-cache')));
$response = curl_exec($curl);

curl_close($curl);
return $response;
}
$sonuc= postByScrapedData($cityCode, $date, $cookies, $token[1]);

echo $sonuc;
pm den iletişime geçilmiştir