Extraire les liens hypertextes dans un fichier html

Résolu/Fermé
chrisee Messages postés 171 Date d'inscription dimanche 23 février 2014 Statut Membre Dernière intervention 29 juillet 2017 - Modifié par chrisee le 12/03/2016 à 23:49
 UnGars - 16 mars 2016 à 15:06
Bonsoir,

J'aimerais extraire tous les liens dans une page html et les afficher en les alignant en order et proprement,mais cette page contient certains lien dans du codes js
J'ai essayé avec: cat monfichier.html |grep "href=" mais ça m'affiche toujours tout,j'suis pas pro en linux en tout cas,et merci pour l'aide

A voir également:

2 réponses

zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 6 407
13 mars 2016 à 08:30
Salut,

Essaie avec
grep -o 'http://[^"]*'  tonfichier.html

0
chrisee Messages postés 171 Date d'inscription dimanche 23 février 2014 Statut Membre Dernière intervention 29 juillet 2017 10
13 mars 2016 à 21:52
Merci,mais il fallait ajouter l'interrupteur -E pour les expressions regulieres:
grep -oE 'http://[^"]*' monfichier.html et pour omettre l'interrupteur -E je fais egrep à la place
0
dindoun Messages postés 1027 Date d'inscription mercredi 23 janvier 2008 Statut Membre Dernière intervention 17 février 2017 135 > chrisee Messages postés 171 Date d'inscription dimanche 23 février 2014 Statut Membre Dernière intervention 29 juillet 2017
Modifié par dindoun le 15/03/2016 à 15:05
salut
pas mal, mais ne marche pas convenablement avec ça :

d to edit your /etc/fstab file and add
"user_xattr" to the mount options. For more information take a look at: <a class="extern" target="_blank" href="https://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support">https://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support</a> (just skip the Kernel configuration part as it is now default in almost all distributions)</p>


car j'obtiens

https://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support
https://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support</a> (just skip the Kernel configuration part as it is now default in almost all distributions)</p>
0
UnGars > dindoun Messages postés 1027 Date d'inscription mercredi 23 janvier 2008 Statut Membre Dernière intervention 17 février 2017
15 mars 2016 à 15:08
Salut,

Essaye avec ça :
grep -o 'http://[^"<]*'  


$ cat fich
d to edit your /etc/fstab file and add
"user_xattr" to the mount options. For more information take a look at: <a class="extern" target="_blank" href="http://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support">http://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support</a> (just skip the Kernel configuration part as it is now default in almost all distributions)</p>

$ grep -o 'http://[^"<]*' fich
http://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support
http://wiki.gentoo.org/wiki/Netflix/Pipelight#Adding_support
0
chrisee > dindoun Messages postés 1027 Date d'inscription mercredi 23 janvier 2008 Statut Membre Dernière intervention 17 février 2017
15 mars 2016 à 17:23
Si tu es sous debian,c'est mieux d'allumer le switch "-E",ça devrait normaleme marcher:
grep -oE 'http://[^"]*' monfichier.html


Ou fais
egrep -o 'http://[^"]*' monfichier.html
0
zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 6 407 > chrisee
15 mars 2016 à 17:53
Salut,

Même sous Debian, sans le "-E" ça passe ;-))

   Basic vs Extended Regular Expressions
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, \+, \{, \|, \(, and \).

Traditional egrep did not support the { meta-character, and some egrep implementations support \{ instead, so portable scripts should avoid { in grep -E patterns and should use [{] to match a literal {.

GNU grep -E attempts to support traditional usage by assuming that { is not special if it would be the start of an invalid interval specification. For example, the command grep -E '{1' searches for the two-character string {1 instead of reporting a syntax error in the regular expression. POSIX allows this behavior as an extension, but portable scripts should avoid it.
0
Utilisateur anonyme
13 mars 2016 à 10:08
Si tu as lynx d'installé :

lynx -dump 'http://tonlien.com'
0