1

<td valign="top" class="notizia_testo"></td>このURLから間のテキストを取得したい

http://www.ladige.it/news/2008_lay_notizia_01.php?id_cat=4&id_news=100152

simple html domとを試しphp regular-expressionましたが、何も返されませんでした。HTMLの生コードを確認し、次のようにコピーしました。

<?php
$str = <<<EOT
//all the html raw code
EOT;
preg_match_all("|<td valign=\"top\" class=\"notizia_testo\">([^^]*?)</td>|u", $str, $matches1);
print_r($matches1);
?>

最終的に、次の原因で障害が発生する可能性があることがわかりました。

line 762     <!?php include($_SERVER["DOCUMENT_ROOT"]."/include/adv/manzoni_bigrect.php"); ?>

この一線を越えて、私のために働く方法は? ありがとう。

4

1 に答える 1

4

以下のようにsimple_html_domを使用するだけで結果を取得できます。

    require 'simplehtmldom/simple_html_dom.php'; 

    $data = file_get_contents('http://www.ladige.it/news/2008_lay_notizia_01.php?id_cat=4&id_news=100152');
    $oHTML = str_get_html($data);
    $oTDs = $oHTML->find('table tr td.notizia_testo');
    $result = array();
    foreach($oTDs as $oTD) {
        $result[] = trim($oTD->plaintext);
    }
    echo "<pre>";
    var_dump($result);
    echo "</pre>";
于 2011-03-14T10:44:59.327 に答える