Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Fichier exporter de Screaming Frog
- $filename = dirname(__FILE__).'/client_error_(4xx)_inlinks.csv';
- // URL DE WEBMACHINE (VERIFIER LA DATE DU SNAPSHOT)
- $web_marchine = 'https://web.archive.org/web/20180629124703im_/';
- // L'URL DE VOTRE SITE
- $url = 'https://blog.vincent-guesne.fr';
- // Parse le CSV
- $all_records = explode( "\n", file_get_contents( $filename ) );
- foreach($all_records as $record){
- // Transforme la ligne actuel en tableau
- $record = str_getcsv($record);
- // Ne le faire que pour les images
- if( $record[0] == 'IMG'){
- // Récupération de la destination
- $img_path = $record[2];
- // remplace le chemin
- $path_dir = str_replace( $url , '' , $img_path );
- $filename = basename( $path_dir );
- $path_dir = '.'.str_replace( $filename , '' , $path_dir );
- // Creation du chemin en local
- if( !file_exists( $path_dir )){
- mkdir( $path_dir , 0755 , true );
- }
- $path_img = $path_dir . $filename;
- // DOWNLOAD
- if ( !file_exists( $path_img ) ){
- $file = file_get_contents( $web_marchine .$img_path );
- file_put_contents( $path_img , $file );
- }
- }
- }
- // YA PU KA FTPISSER TOUT CA
Add Comment
Please, Sign In to add comment