0

I try to get all <tr> from a site with cURL. Today i have this HTML code, and now i want to get every tr:

       <tr>
            <th colspan="7">2019/20</th>
        </tr>
        <tr>
            <th style="width:30%;">row</th>
        </tr>

                <tr>
                    <td>colum</td>
                    <td>colum</td>
                </tr>

                <tr>
                    <td>colum</td>
                    <td>colum</td>
                </tr>

                <tr>
                    <td>colum</td>
                    <td>colum</td>
                </tr>                


        <tr>
            <th colspan="7">2018/19</th>
        </tr>

I have try with this PHP code:

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
$tr = explode('<tr>', $html);
$tr = explode('</tr>', $tr[1]);
$tr = strip_tags($tr[0]);
echo $tr;

How can i get every <tr> in a array?

  • curl just gets the document. It's not going to extract specific parts like ``. Take a look at https://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php for that part. – Don't Panic Jan 29 '20 at 00:00
  • Here's a specific example for a table: https://stackoverflow.com/questions/8816194/how-to-parse-html-table-using-php – Don't Panic Jan 29 '20 at 00:04

0 Answers0