Je ne comprend pas la page est bien valide....
http://www.boursorama.com/tableaux/cour ... CHE=1rPCAC
Le problème c'est qu'il n'y a pas beaucoup de valeur (CAC40, ...)
Code : Tout sélectionner
libxml_use_internal_errors(true);
$html = "http://www.boursorama.com/tableaux/cours_az.phtml?MARCHE=1rPCAC";
$dom = new DomDocument();
$dom->loadHTMLFile($html);
$xpath = new DomXPath($dom);
$item = $xpath->query('//a[text()="ACCOR"]/../../td[position()=3]/text()')->item(0);
var_dump($item->nodeValue);
Code : Tout sélectionner
Notice: Trying to get property of non-object in
NULL
libxml_use_internal_errors(true);
$dom = new DomDocument();
$dom->loadHTMLFile('http://www.boursorama.com/tableaux/cours_az.phtml?MARCHE=1rPCAC');
$xpath = new DomXPath($dom);
$item = $xpath->query('//a[text()="ACCOR"]/../../td[position()=4]/text()')->item(0);
var_dump($item->nodeValue);Code : Tout sélectionner
$xpath->query('//a[text()="ACCOR"]/../../td[position()=3]/text()')->item(0);
<tr onclick="document.location.href='/cours.phtml?symbole=1rPAC'" id="btable1275949971_row0" class="L10">
<td align="center"><img src="http://img.boursorama.com/i/block/flechedown.gif" width="7px" height="9px" border="0" alt="" /></td>
<td class="gras"><a rel="rowlink" href="/cours.phtml?symbole=1rPAC">ACCOR</a></td>
<td align="center"><img src="http://img.boursorama.com/i/delay_R.gif" border="0" title="Données temps réel"></td>
<td align="right">38.875(c)</td>
<td class="gras" align="right"><span class="color2">-0.75%</span></td>
<td align="right">38.640(c)</td>
<td align="right">39.685(c)</td>
<td align="right">38.600(c)</td>
<td class="gras" align="center"><span class="color3">+1.63%</span></td>
<td align="right">751 813</td>
</tr>
//a : va chercher toutes les balises de type "a" (donc lien)Code : Tout sélectionner
substr($val, 11, 4);
Cela fonctionneMERCI
Dernière petite question, j'aimerais extraire simplement le resultat et supprimer : string(9)
J'ai essayer avec :
Code : Tout sélectionner
substr($val, 11, 4);
echo $item->nodeValue;Code : Tout sélectionner
Notice: Trying to get property of non-object in