par
papipasto » 20 oct. 2006, 10:58
Bon alors j'ai essayé un autre truc :
<?php
$handle = fopen("http://www.domainedistant.com/index.html", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
preg_match('#<a href=\"(.*)\".*>(.*?)</a>#', $contents, $out);
print_r($out);
?>
Là je récupère qu'une seule occurance de mon pattern alors qu'il y en a deux.
Je vous mets le code html que je parse pour exemple :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript type=text/JavaScript>
function popupcenter(url, fen_width, fen_height, nom)
{
var top_pos = (screen.height - fen_height)/2
var left_pos = (screen.width - fen_width)/2
var nouvpopupcenter=window.open(url,nom,"status=yes,resizable=no,scrollbars=no,width="+fen_width+",height="+fen_height+",top="+top_pos+",left="+left_pos);
nouvpopupcenter.focus();
}
</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td width="50%" align="right"></td>
<td width="50%"><p class="Accrochebleuebig">Diffusion live</p>
<p><a href="javascript:popupcenter('http://www.domainedistant.com/live.php?video=wmp&debit=haut', 698, 457,'conseil' )">Live</a></p>
<p><a href="javascript:popupcenter('http://www.domainedistant.com/rediff.php?video=wmp&debit=haut', 698, 457,'conseil' )">Rediffusion</a></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Alors voilà je fais appel à un pro de l'expression régulière

Merci de votre aide.
Bon alors j'ai essayé un autre truc :
[php]
<?php
$handle = fopen("http://www.domainedistant.com/index.html", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
preg_match('#<a href=\"(.*)\".*>(.*?)</a>#', $contents, $out);
print_r($out);
?>
[/php]
Là je récupère qu'une seule occurance de mon pattern alors qu'il y en a deux.
Je vous mets le code html que je parse pour exemple :
[php]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript type=text/JavaScript>
function popupcenter(url, fen_width, fen_height, nom)
{
var top_pos = (screen.height - fen_height)/2
var left_pos = (screen.width - fen_width)/2
var nouvpopupcenter=window.open(url,nom,"status=yes,resizable=no,scrollbars=no,width="+fen_width+",height="+fen_height+",top="+top_pos+",left="+left_pos);
nouvpopupcenter.focus();
}
</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td width="50%" align="right"></td>
<td width="50%"><p class="Accrochebleuebig">Diffusion live</p>
<p><a href="javascript:popupcenter('http://www.domainedistant.com/live.php?video=wmp&debit=haut', 698, 457,'conseil' )">Live</a></p>
<p><a href="javascript:popupcenter('http://www.domainedistant.com/rediff.php?video=wmp&debit=haut', 698, 457,'conseil' )">Rediffusion</a></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
[/php]
Alors voilà je fais appel à un pro de l'expression régulière :)
Merci de votre aide.