HTTP/1.1 302 Moved Temporarily
Server: nginx/1.10.2
Date: Fri, 25 May 2018 19:27:10 GMT
Content-Type: text/html
Content-Length: 161
Connection: keep-alive
Location: http://домен.ru/1.jpg
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 25 May 2018 19:28:38 GMT
Content-Type: image/jpeg
Content-Length: 46714
Last-Modified: Sun, 30 Aug 2015 17:54:53 GMT
Connection: keep-alive
ETag: "55e3436d-b67a"
Accept-Ranges: bytes
HTTP/1.1 200 OK
Server: nginx/1.10.2
Date: Fri, 25 May 2018 19:26:09 GMT
Content-Type: image/png
Content-Length: 728807
Last-Modified: Tue, 14 Nov 2017 18:13:27 GMT
Connection: keep-alive
ETag: "5a0b3247-b1ee7"
Accept-Ranges: bytes
HTTP/1.1 404 Not Found
Server: nginx/1.10.2
Date: Fri, 25 May 2018 19:26:17 GMT
Content-Type: text/html
Content-Length: 3652
Connection: keep-alive
ETag: "58173b0b-e44"
<?php
$filename = '21.xml';
if (file_exists($filename)) {
echo "Файл $filename существует";
} else {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://домен.ru/текст/текст/текст/текст");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_REFERER,'http://домен.ru');
$file = curl_exec($ch);
curl_close($ch);
$data = fopen("21.xml","w");
fputs($data,$file);
fclose($data);
echo "Файл $filename не существует";
}
?>
curl_setopt($ch, CURLINFO_REDIRECT_COUNT, 0);