du7133 2015-01-17 15:47
浏览 25
已采纳

使用PHP Simple HTML DOM刮取数据

I structure like this:

<tr>
    <td>
        <strong>Tel. nr.:</strong>
        +370 000 000
        <strong>Faksas:</strong>
        +370 5 0000
    </td>
</tr>

I new in using Simple HTML DOM. What I need, I need content +370 000 000 and +370 5 0000 . I see that this library does not support Xpath, how can I write a query where I can extract the contents after the HTML link <strong>Tel. nr.:</strong> ?

I found only one way, get HTML and with regex get text from </strong> till <strong>, but maybe Simple HTML DOM have own method for this?

  • 写回答

2条回答 默认 最新

  • douji0108 2015-01-17 15:56
    关注

    Try like this...

       <?php
        require('simple_parser.php');
        $html = str_get_html('
        <tr>
            <td>
                <strong>Tel. nr.:</strong>
                +370 000 000
                <strong>Faksas:</strong>
                +370 5 0000
            </td>
        </tr>');
        $td =$html->find('td',0) ; 
        echo $td->plaintext;
    
        ?>
    

    Post your full code to get a clear answer

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?