Skip to content

Instantly share code, notes, and snippets.

@hcivelek
Last active February 16, 2022 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hcivelek/f2729f1eee6ab12d084dbd1858182e74 to your computer and use it in GitHub Desktop.
Save hcivelek/f2729f1eee6ab12d084dbd1858182e74 to your computer and use it in GitHub Desktop.
<?php
function getCode(){
$url="https://www.istanbuleczaciodasi.org.tr/nobetci-eczane/index.php";
$html = file_get_contents($url);
preg_match('/<input type="hidden"[^<]+\/>/', $html, $output);
$a = explode(' ',str_replace(['<','/>'],'',$output[0]));
$val = str_replace(['value="','"'],'',$a[count($a)-1]);
return $val;
}
function getJson($ilce){
$kod = getCode();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.istanbuleczaciodasi.org.tr/nobetci-eczane/index.php',
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 => array('islem' => 'get_ilce_eczane','ilce' => $ilce,'jx' => '1','h' => $kod),
CURLOPT_HTTPHEADER => array(
'Cookie: COOKIE_DEVICE=desktop; PHPSESSID=j4rs5psi69kub6iquf02tr88r8'
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
echo getJson($_GET['ilce']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment