0

I want to extract only a select number of rows from a table that exists on an external site. I am using the response in the following post as a start to extract the entire table:

PHP Data Extraction From External Website, Then Write to Database

It works great for getting the whole table, but what I want to accomplish is as follows.

1) exclude the first row

2) include the next 7 rows

3) exclude the rest of the table

Can this be done?

Community
  • 1
  • 1
user1687533
  • 43
  • 2
  • 9
  • 1
    Yes this can be done. What did you come up with when researching the problem at hand? Why didn't it work for you? Where are you stuck? – PeeHaa Apr 29 '14 at 10:12
  • What I started to find dealt with regular expression, which is beyond my scope of experience. – user1687533 Apr 29 '14 at 10:14
  • possible duplicate of [How do you parse and process HTML/XML in PHP?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – PeeHaa Apr 29 '14 at 10:15
  • I can get the entire table, but to manipulate the data retrieved to get only the rows I want is where I am stuck. – user1687533 Apr 29 '14 at 10:16
  • See the linked question. My preference is http://nl3.php.net/manual/en/class.domdocument.php – PeeHaa Apr 29 '14 at 10:16

1 Answers1

0

For my specific purposes I used the following class http://sourceforge.net/projects/simplehtmldom/

And the following php code to get exactly what I want from the html table I am scraping.

    <?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>
user1687533
  • 43
  • 2
  • 9