How to bypass the accept cookies of a website with curl when running the script from a cron on a shared host in PHP?
I would like first to thank anyone who reads my question and tries to help or at least takes the time to read it. I searched a lot on google and on other questions asked here but i couldn't get a clear answer or know if it is related to what i am trying to do exactly. What i am trying to do is: run a cron job script from which i open a google link using curl from a shared host, but the script being stopped with the accept cookies from google. So how can I bypass that ?
here is my curl code:
$useragent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36';
$timeout= 120;
$url = "https://www.google.com/search?q=world&sxsrf=ALeKk03Q7YEL-UvJX8ODpnmiobrSDNORNg:1624631368943&source=lnms&tbm=nws";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_ENCODING, "" );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_AUTOREFERER, true );
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
$content = curl_exec($ch);
if(curl_errno($ch)){
echo 'error:' . curl_error($ch);
} else {
$link = $content;
echo $link;
}
curl_close($ch);
source https://stackoverflow.com/questions/68154350/how-to-bypass-the-accept-cookies-of-a-website-with-curl-when-running-the-script
Comments
Post a Comment