简体   繁体   中英

Get specific target or data on table in other website using curl PHP

I have a question, please go to this site https://bri.co.id/web/guest/deposit-interest-rate . On the page you will find this table:

在此处输入图片说明

How can I get only the data in that circle on that picture using cURL PHP ?

In my code I'm using $dom->getElementsByTagName('tbody'); but its showing all data on the table. Sorry for my bad English I'm Korean.

Check this code

<?php
$url = "https://bri.co.id/web/guest/deposit-interest-rate";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$html = curl_exec($ch);
curl_close($ch);

preg_match("'<td style=\"font-weight: bold; text-align: center;\">(.*?)</td> <td style=\"text-align: center;\">(.*?)</td> <td style=\"text-align: center;\">(.*?)</td>'si", $html, $match);

if ($match) {
    echo $match[1] . '<br />';
    echo $match[2] . '<br />';
    echo $match[3] . '<br />';
}

And the result is:

< 100 Juta
1
4.75%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM