В моем случае страницы имеют несколько table
с тем же классом, поэтому я нахожу значение с помощью tr, td and plaintext
.
PHP Part:
$html = file_get_html('http://www.example.com/');
$eles = $html->find('.info-tab');
foreach($eles as $e) {
if(strpos($e->find('tr',0)->plaintext, "Information about the manufacturer and the model." ) ) {
$value1 = $e->find('td',1)->plaintext;
}
if(strpos($e->find('tr',1)->plaintext, "Information about the manufacturer and the model." ) ) {
$value2 = $e->find('td',1)->plaintext;
}
}
echo $value1;
echo $value2;
Веб-страница
// Here's will be many other "Table" with diffrent text but class & ID are same...
<table class="info-tab">
<tbody>
<tr>
<td>Information about the manufacturer and the model.</td>
<td>1000</td>
</tr>
<tr>
<td>dummy text</td>
<td>dummy text</td>
</tr>
</tbody>
</table>
// Here's will be many other "Table" with diffrent text but class & ID are same...
<table class="info-tab">
<tbody>
<tr>
<td>dummy text</td>
<td>dummy text</td>
</tr>
<tr>
<td>Information about the manufacturer and the model.</td>
<td>3000</td>
</tr>
<tr>
<td>dummy text</td>
<td>dummy text</td>
</tr>
</tbody>
</table>
// Here's will be many other "Table" with diffrent text but class & ID are same...
Страница содержит несколько таблиц 20 плюс, только две таблицы имеют этот текст, поэтому я хочу их скопировать.
Как найтиэти два значения?