Answer the question
In order to leave comments, you need to log in
How to pull file link from Location header?
Hello !
I can't think of a solution to this problem.
There is a link to the program: www.softportal.com/get-18737-nero-burning-rom.html
and there is a link: Source 1 - Download
When you click on "Download", the site checks the cookie that it issued at the entrance and the file download starts (site gives the browser a URL in the Location header with a direct link to the .exe file).
--------------------------------------------------
How do I access the site and get cookies so that you can get the Location with a direct link to the exe-file (if there are no cookies, then the site issues the "left" Location) ?
This example doesn't work:
<?php
$headers = array
(
'Host: www.softportal.com',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding: gzip, deflate, sdch',
'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
'Upgrade-Insecure-Requests: 1',
'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36'
);
if( $curl = curl_init() ) {
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_URL,'http://www.softportal.com/getsoft-18737-nero-burning-rom-2.html'); // -- ссылка на "Скачать"
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_NOBODY,true);
curl_setopt($curl, CURLOPT_HEADER,true);
curl_setopt($curl, CURLOPT_REFERER, 'http://www.softportal.com/');
curl_setopt($curl, CURLOPT_USERAGENT, 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36 OPR/31.0.1889.174');
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
//curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$out = curl_exec($curl);
echo $out;
curl_close($curl);
}
?>
Content-Type: text/html
Date: Fri, 09 Oct 2015 14:28:44 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Location: http://mirrorf.donmare.net/b4/3/1/85fedbcda2057dc2487b472ded871011/neroburningrom2016-17.0.00300_trial.exe
Pragma: no-cache
Server: Apache/2.2.15 (CentOS)
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.3
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question