我有一个问题,请转到此网站https://bri.co.id/web/guest/deposit-interest-rate。在页面上,您将找到此表:
如何使用cURL PHP仅获取该图片上该圆圈中的数据?
在我的代码中,我使用的是$dom->getElementsByTagName('tbody');
,但它显示了表中的所有数据。对不起,我的英语不好,我是韩国人。
答案 0 :(得分:0)
检查此代码
<?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 />';
}
结果是:
< 100 Juta
1
4.75%