Extraire les liens hypertextes dans un fichier html

Résolu
chrisee Messages postés 212 Statut Membre -  
 UnGars -
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 38797 Statut Contributeur 6 433
 
Salut,

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

0
chrisee Messages postés 212 Statut Membre 10
 
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 1047 Statut Membre 135 > chrisee Messages postés 212 Statut Membre
 
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 1047 Statut Membre
 
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 1047 Statut Membre
 
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 38797 Statut Contributeur 6 433 > chrisee
 
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
 
Si tu as lynx d'installé :

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