dongpao5261 2018-11-23 02:41
浏览 61

使用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:

enter image description here

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.

  • 写回答

1条回答 默认 最新

  • dpojoxa5613 2018-11-23 03:26
    关注

    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%
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号