#1 Le 03/09/2007, à 23:07
- compte supprimé
un sed pour extraire des chaînes (url) puis faire des wget en boucle
Bonjour
J'ai un bout d'htlm issu de mon cache Firefox qui se présente comme suit :
[...]
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/firefox/clear.gif">http://www.google.fr/images/firefox/clear.gif</a>
<b> Data size:</b> 43 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2038-01-17 20:13:58
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/firefox/footer2.gif">http://www.google.fr/images/firefox/footer2.gif</a>
<b> Data size:</b> 60 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2038-01-17 20:13:58
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/firefox/footer3.gif">http://www.google.fr/images/firefox/footer3.gif</a>
<b> Data size:</b> 814 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2038-01-17 20:13:58
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/firefox/footer1.gif">http://www.google.fr/images/firefox/footer1.gif</a>
<b> Data size:</b> 246 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2038-01-17 20:13:58
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/firefox/title_bg.gif">http://www.google.fr/images/firefox/title_bg.gif</a>
<b> Data size:</b> 432 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2038-01-17 20:13:58
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/nav_logo.png">http://www.google.fr/images/nav_logo.png</a>
<b> Data size:</b> 5063 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:36
<b> Expires:</b> 2038-01-17 20:13:57
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/favicon.ico">http://www.google.fr/favicon.ico</a>
<b> Data size:</b> 1406 bytes
<b> Fetch count:</b> 1
<b> Last modified:</b> 2007-09-03 23:55:36
<b> Expires:</b> 2038-01-17 20:13:57
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.com/ac.js">http://www.google.com/ac.js</a>
<b> Data size:</b> 5067 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2007-09-15 14:56:41
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/firefox/google.gif">http://www.google.fr/images/firefox/google.gif</a>
<b> Data size:</b> 1607 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2038-01-17 20:13:58
<b> Key:</b> <a href="about:cache-entry?client=HTTP&sb=1&key=http://www.google.fr/images/firefox/title.gif">http://www.google.fr/images/firefox/title.gif</a>
<b> Data size:</b> 5261 bytes
<b> Fetch count:</b> 2
<b> Last modified:</b> 2007-09-03 23:55:37
<b> Expires:</b> 2038-01-17 20:13:58
</pre>
</div>
</body></html>
Ce que j'aimerais, c'est extraire toutes les url des medias (httlp://....??? pour les images gif, jgp, etc) rediriger le tout vers un fichier temporaire et faire la boucle ligne à ligne qui va me faire un wget.
Vous voyez le sed en question ?
Ami étudiant doué en info, merci !
#2 Le 04/09/2007, à 00:15
- Yannick_LM
Re : un sed pour extraire des chaînes (url) puis faire des wget en boucle
sed '/Key/!d ; s/^.*key=// ; s/".*$//'
http://www.student.northpark.edu/pement … d1line.txt
Merci à cep pour le lien...
EDIT : je te conseille d'essayer de comprendre comment ça marche, avant de passer à la suite...
Et puis tu n'as pas besoin de passer par un fichier temporaire...
Tu peux te pencher sur la commande xargs, par exemple
Dernière modification par Yannick_LM (Le 04/09/2007, à 00:20)
Trucs et astuces pour Vim
Ma web page avec des trucs dessus ...
Hors ligne