Search code examples
phpdomweb-scrapinghtml-tablesimple-html-dom

Simple html dom parser get tr from table


I am trying to scrap http://spys.one/free-proxy-list/but here i just want get Proxy by ip:port column only i checked the website there was 3 table

Anyone can help me out?

<?php
    require "scrapper/simple_html_dom.php";

    $html=file_get_html("http://spys.one/free-proxy-list/");
    $html=new simple_html_dom($html);

    $rows = array();
    $table = $html->find('table',3);

    var_dump($table);

Solution

  • Try the below script. It should fetch you only the required items and nothing else:

    <?php
    include 'simple_html_dom.php';
    $url = "http://spys.one/free-proxy-list/";
    
    $html = file_get_html($url);
    foreach($html->find("table[width='65%'] tr[onmouseover]") as $file) {
        $data     = $file->find('td', 0)->plaintext;
        echo $data . "<br/>";
    }
    ?>
    

    Output it produces like:

     176.94.2.84
     178.150.141.93
     124.16.84.208
     196.53.99.7
     31.146.161.238