'Extracting data from a site

I'm pulling data from a table using php dom parser, but only 1 row is coming in the table, I want all of them, I don't know if the div class is correct, only 1 data is coming what can I do to get all the data in the table

<?php 

include_once 'simple_html_dom.php';
$dom = new simple_html_dom();

$ch= curl_init('https://www.stats24.com/');
curl_setopt_array($ch, [
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 OPR/73.0.3856.415'
]);

$result = curl_exec($ch);
curl_close($ch);


$dom->load($result);

$c = $dom->find('.general_table_style');

$data = [];

foreach ($c as $item){
    $lig = $item->find("meta[itemprop='name address']")[0]->content;
    $tarih = $item->find("time")[0]-> datetime;
    $saat = $item->find("time")[0]-> plaintext;
    $takim1 = $item->find(".")[0]-> plaintext;
    $takim2 = $item->find(".")[0]-> plaintext;
    $oran = $item->find(".")[0]-> plaintext;
    $data[$lig][] = [
        'tarih' => $tarih,
        'saat' => $saat,
        'takim_1' => $takim1,
        'takim_2' => $takim2,
        'oran' => $oran
        
    ];
    
}


print_r($data);

 ?>

php


Solution 1:[1]

<?php 

include_once 'simple_html_dom.php';
$dom = new simple_html_dom();

$ch= curl_init('https://www.stats24.com/');
curl_setopt_array($ch, [
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 OPR/73.0.3856.415'
]);

$result = curl_exec($ch);
curl_close($ch);


$dom->load($result);

$c = $dom->find('.general_table_style');

$data = array();
$response = array();

foreach ($c as $item){
  $response['lig'] = $item->find("meta[itemprop='name address']")[0]->content;
    $response['tarih'] = $item->find("time")[0]-> datetime;
    $response['saat'] = $item->find("time")[0]-> plaintext;
    $response['takim1'] = $item->find(".")[0]-> plaintext;
    $response['takim2'] = $item->find(".")[0]-> plaintext;
    $response['oran'] = $item->find(".")[0]-> plaintext;
   $data[]=$response;
    
}


print_r($data);

 ?>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jyoti Bhandari