SHARE
TWEET

Recover image from WebArchive

a guest Dec 2nd, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. // Fichier exporter de Screaming Frog
  5. $filename = dirname(__FILE__).'/client_error_(4xx)_inlinks.csv';
  6. // URL DE WEBMACHINE (VERIFIER LA DATE DU SNAPSHOT)
  7. $web_marchine = 'https://web.archive.org/web/20180629124703im_/';
  8. // L'URL DE VOTRE SITE
  9. $url = 'https://blog.vincent-guesne.fr';
  10. // Parse le CSV
  11. $all_records = explode( "\n", file_get_contents( $filename ) );
  12. foreach($all_records as $record){
  13.   // Transforme la ligne actuel en tableau
  14.   $record = str_getcsv($record);
  15.  
  16.   // Ne le faire que pour les images
  17.   if( $record[0] == 'IMG'){
  18.     // Récupération de la destination
  19.     $img_path = $record[2];
  20.     // remplace le chemin
  21.     $path_dir = str_replace( $url , '' , $img_path );
  22.     $filename = basename( $path_dir );
  23.     $path_dir = '.'.str_replace( $filename , '' , $path_dir );
  24.     // Creation du chemin en local
  25.     if( !file_exists( $path_dir )){
  26.       mkdir( $path_dir , 0755 , true );
  27.     }
  28.  
  29.     $path_img = $path_dir . $filename;
  30.     // DOWNLOAD
  31.     if ( !file_exists( $path_img ) ){
  32.       $file = file_get_contents( $web_marchine .$img_path );
  33.       file_put_contents( $path_img , $file );
  34.     }
  35.   }
  36. }
  37. // YA PU KA FTPISSER TOUT CA
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top