Farklı ref, agent, çerez, proxy ile denedim ama sonuç değişmiyor..
// curl kısmı
public function getSourceWithCurl($url)
{
$this->ref = $this->getRandomRef();
$this->agent = $this->getRandomAgent();
$this->proxy = $this->getRandomProxy();
$this->cookie = tempnam("/tmp", "CURLCOOKIE");
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_REFERER => $this->ref,
CURLOPT_USERAGENT => $this->agent,
CURLOPT_PROXY => $this->proxy,
CURLOPT_COOKIEJAR => $this->cookie,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_HEADER => true,
CURLOPT_ENCODING => "",
CURLOPT_AUTOREFERER => true,
CURLOPT_MAXREDIRS => 15
]);
$source = curl_exec($ch);
$status = curl_getinfo($ch);
curl_close($ch);
if ($status['http_code'] != 200) {
if ($status['http_code'] == 301 || $status['http_code'] == 302) {
list($header) = explode("\r\n\r\n", $source, 2);
$matches = array();
preg_match("/(Location:|URI:)[^(\n)]*/", $header, $matches);
$url = trim(str_replace($matches[1], "", $matches[0]));
$url_parsed = parse_url($url);
$url = $url_parsed["scheme"] . "://" . $url_parsed["host"] . $url_parsed["path"] . "?" . urlencode($url_parsed["query"]);
return (isset($url_parsed)) ? $this->getSourceWithCurl($url) : '';
}
}
return $source;
}
random ref oluşturucu
public function getRandomRef()
{
$array = [
"www.google.com",
"www.yandex.com",
"www.bing.com",
"www.youtube.com",
"www.facebook.com",
"www.twitter.com",
"www.linkedin.com",
"www.reddit.com",
"web.whatsapp.com",
];
return $array[array_rand($array)];
}
random proxy
public function getRandomProxy(){
$array = [
"200.29.111.108:45807",
"81.163.43.116:41258",
"177.185.222.176:21776",
"125.167.74.213:53281",
"210.178.172.125:808",
"80.211.103.18:3128",
"46.143.252.33:35693",
"177.137.23.3:80",
"103.232.33.6:32231",
"90.139.89.220:59033",
"177.124.164.26:53281",
"193.93.219.227:31829",
"193.238.111.127:32231",
"213.131.52.102:56914"
];
return $array[array_rand($array)];
}
agent kısmı uzun yazmıyorum ama yukarıdakiler ile aynı mantıkta çalışıyor.