スクレイピングされたデータを取得するために単純な HTML DOM を使用していますが、うまく機能しています。ただし、私が持っているソースの 1 つには一意のフィールドがないため、str_replace を試みてから、名前を変更した要素を取得してから simple_html_dom を使用しています。
しかし、うまくいきません。私のコードは次のとおりです。
require('simple_html_dom.php');
// Create DOM from URL or file
$html = file_get_html('http://www.url.com');
$html = str_replace('<strong>','',$html);
$html = str_replace('</strong>','',$html);
$html = str_replace('<span class="pound">£</span>','',$html);
$html = str_replace('<td>','<td class="myclass">',$html);
foreach($html->find('td.myclass') as $element)
$price = $element->innertext;
$price = preg_replace('/[^(\x20-\x7F)]*/','', $price);
echo $price;