View difference between Paste ID: 5weYFGrR and c0Wk6Sgw
SHOW: | | - or go back to the newest paste.
1
<?php
2
//sites.txt - файл со списком доменов
3
//в результате в файле res.csv будет информация по:
4
//Сайт, год первого скриншота в вебархиве, статус http, год последнего скриншота в вебархиве, статус страницы http код ответа
5
6
$sites = file('sites.txt'); 
7
$lines = count ($sites);
8
$l = $lines;
9
foreach ($sites as $site)
10
{
11
12
echo "сайтов: " . $lines . " осталось: " . --$l . "\r\n";
13
$site = rtrim($site);
14
	$query = 'http://web.archive.org/cdx/search/cdx?url='.$site.'&output=json';
15
	$webarchive = @file_get_contents($query);
16
	$webarchive = json_decode($webarchive);
17
	$c = count ($webarchive);
18
19
	if ($c == 0) {
20
		continue;
21
	}
22
	
23
	if ($c == 2) {
24
		file_put_contents('res.csv', $webarchive[1][2] . ' ; ' . substr($webarchive[1][1],0,4) . ';' . $webarchive[1][4] . "/r/n",FILE_APPEND);
25
	}
26
	else {
27
		file_put_contents('res.csv', $webarchive[1][2] . ' ; ' . substr($webarchive[1][1],0,4) . ';' . $webarchive[1][4] . ' ; ' .$webarchive[$c-1][2] . ' ; ' . substr($webarchive[$c-1][1],0,4) . ';' . $webarchive[$c-1][4] . "\r\n",FILE_APPEND);
28
	}
29
}
30
31
?>