php 仅从外部表中提取选定的行

问题描述 投票:0回答:1

我只想从外部站点上存在的表中提取选定数量的行。我使用以下帖子中的响应作为提取整个表格的开始:

PHP从外部网站提取数据,然后写入数据库

它对于获取整个表格非常有用,但我想要完成的任务如下。

1) 排除第一行

2) 包括接下来的 7 行

3) 排除表中的其余部分

这可以吗?

php regex web-scraping curl dom
1个回答
0
投票

出于我的特定目的,我使用了以下课程 http://sourceforge.net/projects/simplehtmldom/

下面的 php 代码可以从我正在抓取的 html 表中准确获取我想要的内容。

    <?php 

    include('../includes/simple_html_dom.php');

    $html = file_get_html('http://listhoopla.com/r.cgi/276');

    $ret = $html->find('tr');

    ?><table><?
    $x=1;
    while($x<8){
    echo $ret[$x];
    $x++;
    }
    ?>
    </table>
© www.soinside.com 2019 - 2024. All rights reserved.