Gehe zu deutscher Webseite

ViaThinkSoft CodeLib

This article is in:
CodeLib → Programming aids → PHP

<?php

function get_all_wayback_timestamps($url) {
    
// TODO: muss $url irgendwie encoded werden?

    
$cont = file_get_contents('http://wayback.archive.org/web/*/'.$url);
    
$pattern = '|going all the way back to <a href="http://web.archive.org/web/(d{4})|ismU';
    
preg_match_all($pattern, $cont, $m);

    if (!isset(
$m[1][0])) return false;
    
$startjahr = $m[1][0];

    
$outary = array();
    for (
$year=$startjahr; $year<=date('Y'); $year++) {
        
$curl = 'http://wayback.archive.org/web/'.$year.'0000000000*/'.$url;
        
$cont = file_get_contents($curl);

        
$pattern = '|<a href="http://web\\.archive\\.org/web/(d{14})/|ismU';

        
preg_match_all($pattern, $cont, $m);

        foreach (
$m[1] as $t) {
            if (!
in_array($t, $outary)) {
                
$outary[] = $t;
            }
        }
    }

    return 
$outary;
}

?>
Daniel Marschall
ViaThinkSoft Co-Founder