Имею такую функцию, через которую делаю запрос:
if(!function_exists('request')) {
function request($method = "GET", $url = null, $params = null, $proxy = null, $proxy_userpwd = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');;
if($method == "POST") {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params['params']);
} else {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
}
if(isset($params['headers'])) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $params['headers']);
}
if(isset($params['cookies'])) {
curl_setopt($ch, CURLOPT_COOKIE, $params['cookies']);
}
if($proxy) {
curl_setopt($ch, CURLOPT_PROXY, $proxy);
if($proxy_userpwd) {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_userpwd);
}
}
$result = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($result, 0, $header_size);
$content = substr($result, $header_size);
preg_match_all('|Set-Cookie: (.*);|U', $headers, $parse_cookies);
$cookies = implode(';', $parse_cookies[1]);
curl_close($ch);
return array('headers' => $headers, 'cookies' => $cookies, 'content' => $content);
}
}
Передаю заголовки:
$headers = array();
$headers[] = 'Authority: lolz.guru';
$headers[] = 'DNT: 1';
$headers[] = 'Upgrade-Insecure-Requests: 1';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36';
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9';
$headers[] = 'Sec-Fetch-Site: none';
$headers[] = 'Sec-Fetch-Mode: navigate';
$headers[] = 'Sec-Fetch-User: ?1';
$headers[] = 'Sec-Fetch-Dest: document';
$headers[] = 'Accept-Language: ru,en;q=0.9,ru-RU;q=0.8,en-US;q=0.7';
$headers[] = 'If-Modified-Since: Fri, 15 May 2020 14:16:00 GMT';
Вызываю функцию и получаю пустой контент:
$page = request('GET', 'https://lzt.guru/', ['headers' => $headers]);
print_r($page);
На сайте стоит защита от парсинга, если знаете, как можно решить эту проблему, можете оставить свой TG за $$$