Merhaba arkadaşlar, curl ile bir siteye bağlanmaya çalışırken "please enable cookies" şeklinde uyarı veriyor ve siteye bağlanamıyorum. Yardımcı olurmusunuz?
Kullandığım kodlar ve aldığım uyarı şu şekilde;
<?php
$cookies = 'cookies.txt';
function Baglan($url) {
$ch = curl_init();
//$hc = "YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; Yahoo! Search - Web Search)";
curl_setopt($ch, CURLOPT_REFERER, 'http://google.com/bot.html');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1 );
//curl_setopt($ch, CURLOPT_PROXY, '172.98.170.26:53925');
curl_setopt( $ch , CURLOPT_HEADER , 1 );
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch,CURLOPT_COOKIEJAR,"cookies.txt");
curl_setopt($ch,CURLOPT_COOKIEFILE,"cookies.txt");
//curl_setopt($ch,CURLOPT_COOKIE,"__cfduid="."$cookies");
$cikti = curl_exec($ch);
curl_close($ch);
//return str_replace(array("\n","\t","\r"),null,$cikti);
return $cikti;
}
$html = Baglan('https://www.uswebsitecreations.com/'); // Siteye bağlan
//$html = file_get_html('http://www.google.com/'); // Bu şekildede kullanılabilir.
//echo $html;
/*foreach($html->find('a') as $element) // Sitedeki tüm "a" elementlerini ara
{
echo $element->href . '<br>'; // Foreach ile saydaki "a" elementi kadar döndür. Ve "href" değeri ile linke ulaş
}
*/
echo $html;
exit;Aldığım uyarı görünrüsü burada
http://prntscr.com/kpgkm7