3
I have a little difficulty to assemble the regular expressions, I’m trying to work with this code:
<?php
$url = file_get_contents('http://ciagri.iea.sp.gov.br/precosdiarios/');
preg_match_all($expressao, $url, $conteudo);
echo $conteudo;
?>
I need to pick up the prices between these codes:
<tr style="background-color:White;">
<td style="width:170px;">
Mandioca para mesa
</td>
<td style="width:120px;">
Mogi Mirim
</td>
<td align="right" style="width:70px;">
11,50
</td>
<td align="center" style="width:70px;">
cx.23 kg
</td>
<td style="width:200px;">
<div id="ctl00_ContentPlaceHolder1_gridRecebidos_ctl95_PanelGridObs">
</div>
</td>
</tr>
<tr>
<td style="width:170px;">
Mandioca para mesa
</td>
<td style="width:120px;">
Pindamonhangaba
</td>
<td align="right" style="width:70px;">
28,00
</td>
<td align="center" style="width:70px;">
cx.23 kg
</td>
<td style="width:200px;">
<div id="ctl00_ContentPlaceHolder1_gridRecebidos_ctl96_PanelGridObs">
</div>
</td>
</tr>
<tr style="background-color:White;">
<td style="width:170px;">
Mandioca para mesa
</td>
<td style="width:120px;">
Sorocaba
</td>
<td align="right" style="width:70px;">
8,79
</td>
<td align="center" style="width:70px;">
cx.23 kg
</td>
<td style="width:200px;">
<div id="ctl00_ContentPlaceHolder1_gridRecebidos_ctl97_PanelGridObs">
</div>
</td>
</tr>
To get the price of each city:
-What would be the best standard to use?
You’re looking for content from another web page?
– MarceloBoni
Tip: Do not use regex to parse HTML, take a look at Xpath, YQL and htmlSQL
– fpg1503
Yes, I am wanting to pick up the quotation of a product that is updated daily. I will take a look at Xpath and YQL.
– Rodolfo Oliveira
For PHP there is htmlSQL (https://github.com/hxseven/htmlSQL)
– fpg1503