Bonjour à tous et à toutes.
je cherche a extraire tous s hyperliens d'une page web. Je me sers donc de cette petite regexp sympathique
El fonctionne a merveil mais voila que j'ai un site ou il y a énormément de balise <area ...>
Donc après plusieurs test voici s résultats que je ne comprend pas très bien...
Jusqu'à 7 liens ca marche
| Code : |
Séctionner tout -
Visualiser dans une fenêtre à part |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <area shape="poly" coords="..." href="lien1.html" tit="tit1">
<area shape="poly" coords="..." href="lien2.html" tit="tit2">
<area shape="poly" coords="..." href="lien3.html" tit="tit3">
<area shape="poly" coords="..." href="lien4.html" tit="tit4">
<area shape="poly" coords="..." href="lien5.html" tit="tit5">
<area shape="poly" coords="..." href="lien6.html" tit="tit6">
<area shape="poly" coords="..." href="lien7.html" tit="tit7">
pattern : '#(<a[^<>]*?href=["\'](.+?)["\'].*?>(.*?)</a>)|(<form[^<>]*?action=["\'](.+?)["\'].*?>)|(<area[^<>]*?href=["\'](.+?)["\'].*?>)#'
Résultat :
( 0 => '<area shape="poly" coords="..." href="lien1.html" tit="tit1">'
1 => ''
2 => ''
3 => ''
4 => ''
5 => ''
6 => '<area shape="poly" coords="..." href="lien1.html" tit="tit1">'
7 => 'artic408.html'
) |
Et a 8 ca plante...
| Code : |
Séctionner tout -
Visualiser dans une fenêtre à part |
1 2 3 4 5 6 7 8 9 10 11 12
| <area shape="poly" coords="..." href="lien1.html" tit="tit1">
<area shape="poly" coords="..." href="lien2.html" tit="tit2">
<area shape="poly" coords="..." href="lien3.html" tit="tit3">
<area shape="poly" coords="..." href="lien4.html" tit="tit4">
<area shape="poly" coords="..." href="lien5.html" tit="tit5">
<area shape="poly" coords="..." href="lien6.html" tit="tit6">
<area shape="poly" coords="..." href="lien7.html" tit="tit7">
<area shape="poly" coords="..." href="lien8.html" tit="tit8">
pattern : '#(<a[^<>]*?href=["\'](.+?)["\'].*?>(.*?)</a>)|(<form[^<>]*?action=["\'](.+?)["\'].*?>)|(<area[^<>]*?href=["\'](.+?)["\'].*?>)#'
Pas de match |
Quelqu'un pourrait m'expliquer pourquoi et s'il y a un moyen de pallier ce problème ?
Partager