Answer the question
In order to leave comments, you need to log in
Why can't curl download this link?
$url = 'https://credits-pl.ru/offer/kredit-911/';
$curl = curl_init();
$cookie = __DIR__ .'/cookie/cookie.txt';
$user_agent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36";
$headers = [
'Referer: http://www.google.com/',
"User-Agent: $user_agent"
];
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);
$str = curl_exec($curl);
Answer the question
In order to leave comments, you need to log in
if you are interested in experimenting with the code - then yourself !
if the solution is google.com
here is the first search output
Add to the code
And it will immediately be clear what is happening.
If the server returned 200, then it was he who decided that there was no need to do a redirect further.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question