Scripts | Codes

All languages in three languages :-)
Showing posts with label une ligne. Show all posts

Extraire des liens d'un fichier (images, pages HTML, pdf, ...) et l'affiche dans le Terminal ou les télécharger avec wget (en une seul ligne).
Vous pouvez choisir les extensions que vous voulez extraire entre les dernières parenthèses séparées par des |
Dans l'exemple on extrait les lien des images d'un fichier index.php puis on les télécharge
On utilise un RegExp de type Perl avec -P

Extract links from a file (images, HTML pages, pdf, ...) and displays them in the Terminal or downloads them with wget (in only one line of code).
You can choose which extensions you want to extract by specifying them inside the last parentheses separated by |
In the example we extract the images link to a index.php file and then downloads them
It uses a Perl-type RegExp with -P

يستخرج كل أنواع الروابط من ملف في Terminal
ثم يمكن تحميلها بإستعمال wget

يمكنك إختيار التمديدات بكتابتها بين القوسين مفصولة ب |
في هذا المثال نستخرج كل روابط الصور ثم نحملها 
يستخدم ريجيكس من نوع Perl 

Open in a new window
wget `cat index.php | grep -P -o 'http:(\.|-|\/|\w)*\.(gif|jpg|png|bmp)'`



Lit un fichier...

... et retourne le résultat en une ligne.
Pour récupérer le fichier en son état original enlever rtrime().

Reads a file ...

... and returns the result in one line.
To retrieve the file in its original condition please remove rtrim().

...يقرأ ملف

و يرجع النتيجة في خط واحد 
  rtrime‎‎‎‎()  لإسترجاع الملف في حالته الأولى إزالة  

Open in a new window
<?
//#################################################
// find more codes on scripts-n-codes.blogspot.com
//#################################################
function read_from_file ($file) {
 $handle = @fopen($file, "r");
 $data = '';
 if ($handle) {
  while (!feof($handle)) {
   $buffer = fgets($handle, 4096);
   $data .= $buffer;
  }
  fclose($handle);
 }
 return rtrim($data);
}
?>

Subscribe to: Posts (Atom)
attendez....