Answer the question
In order to leave comments, you need to log in
How to get data from ajax request using curl?
I'm trying to get data from an ajax request via curl, tell me what I'm doing wrong
$url = "https://razmerkoles.ru/size/bmw/x6/2018";
function getCurlResult ($url) {
global $arrProxy;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLPROTO_HTTPS,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, "103.239.54.56:45462");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);// таймаут в секундах
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134');
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, "C:\Users\vova_\AppData\Local\Google\Chrome\User Data\Default\Cookies");
curl_setopt($ch, CURLOPT_COOKIEFILE, "C:\Users\vova_\AppData\Local\Google\Chrome\User Data\Default\Cookies");
$htmltext = curl_exec($ch);
curl_close($ch);
//$htmltext = iconv("CP1251", "UTF-8", $htmltext);
return $htmltext;
}
$zz = 0;
$html = getCurlResult($url);
$startpos = strpos($html, 'sRwd=\'');// достаю значения атрибута data-rim и data-front
$curlStrCopy = $html;
$startpos +=strlen('sRwd=\'');
$html = substr($html, $startpos);
$endPos = strpos($html, '\';');
$str = substr($curlStrCopy, $startpos, $endPos);
// echo $zz++;
echo "<pre>";
echo $str . "<br>";
echo "</pre>";
$url_site = "https://razmerkoles.ru";
$curl_code = getCurlResult($url_site . $str);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question