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












0















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.










share|improve this question





























    0















    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.










    share|improve this question



























      0












      0








      0








      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.










      share|improve this question
















      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.







      php curl html-table






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 8:07









      Brian Tompsett - 汤莱恩

      4,2031338101




      4,2031338101










      asked Nov 23 '18 at 2:41









      codercoder

      84




      84
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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%





          share|improve this answer


























          • what about NOMINAL -> < 100 Juta ??

            – coder
            Nov 23 '18 at 3:33











          • Maybe because character <, the value of $cols->item(0)->nodeValue is empty. But I can make sure that this code got the right row by the table ID _Deposit_Rate_Display_Portlet_idrRate. If you change $table->getElementsByTagName('tr')[1]; to $table->getElementsByTagName('tr')[7]; , you will get 100 Juta - < 2 Miliyar

            – Van Tho
            Nov 23 '18 at 3:46













          • I was tried $table->getElementsByTagName('tr')[7]; and I just get "100 Juta - " without "< 2 Miliyar". how to resolve this "<" character ?

            – coder
            Nov 23 '18 at 4:07











          • I've tried several ways with Dom but none of it work. How about preg_match? replace Dom code with 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 />'; }

            – Van Tho
            Nov 23 '18 at 7:04













          • Then you will get the result that you want. This way is bad but it works. If you want to get more data from that table, use preg_match_all instead of preg_match

            – Van Tho
            Nov 23 '18 at 7:07











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440052%2fget-specific-target-or-data-on-table-in-other-website-using-curl-php%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          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%





          share|improve this answer


























          • what about NOMINAL -> < 100 Juta ??

            – coder
            Nov 23 '18 at 3:33











          • Maybe because character <, the value of $cols->item(0)->nodeValue is empty. But I can make sure that this code got the right row by the table ID _Deposit_Rate_Display_Portlet_idrRate. If you change $table->getElementsByTagName('tr')[1]; to $table->getElementsByTagName('tr')[7]; , you will get 100 Juta - < 2 Miliyar

            – Van Tho
            Nov 23 '18 at 3:46













          • I was tried $table->getElementsByTagName('tr')[7]; and I just get "100 Juta - " without "< 2 Miliyar". how to resolve this "<" character ?

            – coder
            Nov 23 '18 at 4:07











          • I've tried several ways with Dom but none of it work. How about preg_match? replace Dom code with 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 />'; }

            – Van Tho
            Nov 23 '18 at 7:04













          • Then you will get the result that you want. This way is bad but it works. If you want to get more data from that table, use preg_match_all instead of preg_match

            – Van Tho
            Nov 23 '18 at 7:07
















          0














          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%





          share|improve this answer


























          • what about NOMINAL -> < 100 Juta ??

            – coder
            Nov 23 '18 at 3:33











          • Maybe because character <, the value of $cols->item(0)->nodeValue is empty. But I can make sure that this code got the right row by the table ID _Deposit_Rate_Display_Portlet_idrRate. If you change $table->getElementsByTagName('tr')[1]; to $table->getElementsByTagName('tr')[7]; , you will get 100 Juta - < 2 Miliyar

            – Van Tho
            Nov 23 '18 at 3:46













          • I was tried $table->getElementsByTagName('tr')[7]; and I just get "100 Juta - " without "< 2 Miliyar". how to resolve this "<" character ?

            – coder
            Nov 23 '18 at 4:07











          • I've tried several ways with Dom but none of it work. How about preg_match? replace Dom code with 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 />'; }

            – Van Tho
            Nov 23 '18 at 7:04













          • Then you will get the result that you want. This way is bad but it works. If you want to get more data from that table, use preg_match_all instead of preg_match

            – Van Tho
            Nov 23 '18 at 7:07














          0












          0








          0







          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%





          share|improve this answer















          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%






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 23 '18 at 7:09

























          answered Nov 23 '18 at 3:26









          Van ThoVan Tho

          846




          846













          • what about NOMINAL -> < 100 Juta ??

            – coder
            Nov 23 '18 at 3:33











          • Maybe because character <, the value of $cols->item(0)->nodeValue is empty. But I can make sure that this code got the right row by the table ID _Deposit_Rate_Display_Portlet_idrRate. If you change $table->getElementsByTagName('tr')[1]; to $table->getElementsByTagName('tr')[7]; , you will get 100 Juta - < 2 Miliyar

            – Van Tho
            Nov 23 '18 at 3:46













          • I was tried $table->getElementsByTagName('tr')[7]; and I just get "100 Juta - " without "< 2 Miliyar". how to resolve this "<" character ?

            – coder
            Nov 23 '18 at 4:07











          • I've tried several ways with Dom but none of it work. How about preg_match? replace Dom code with 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 />'; }

            – Van Tho
            Nov 23 '18 at 7:04













          • Then you will get the result that you want. This way is bad but it works. If you want to get more data from that table, use preg_match_all instead of preg_match

            – Van Tho
            Nov 23 '18 at 7:07



















          • what about NOMINAL -> < 100 Juta ??

            – coder
            Nov 23 '18 at 3:33











          • Maybe because character <, the value of $cols->item(0)->nodeValue is empty. But I can make sure that this code got the right row by the table ID _Deposit_Rate_Display_Portlet_idrRate. If you change $table->getElementsByTagName('tr')[1]; to $table->getElementsByTagName('tr')[7]; , you will get 100 Juta - < 2 Miliyar

            – Van Tho
            Nov 23 '18 at 3:46













          • I was tried $table->getElementsByTagName('tr')[7]; and I just get "100 Juta - " without "< 2 Miliyar". how to resolve this "<" character ?

            – coder
            Nov 23 '18 at 4:07











          • I've tried several ways with Dom but none of it work. How about preg_match? replace Dom code with 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 />'; }

            – Van Tho
            Nov 23 '18 at 7:04













          • Then you will get the result that you want. This way is bad but it works. If you want to get more data from that table, use preg_match_all instead of preg_match

            – Van Tho
            Nov 23 '18 at 7:07

















          what about NOMINAL -> < 100 Juta ??

          – coder
          Nov 23 '18 at 3:33





          what about NOMINAL -> < 100 Juta ??

          – coder
          Nov 23 '18 at 3:33













          Maybe because character <, the value of $cols->item(0)->nodeValue is empty. But I can make sure that this code got the right row by the table ID _Deposit_Rate_Display_Portlet_idrRate. If you change $table->getElementsByTagName('tr')[1]; to $table->getElementsByTagName('tr')[7]; , you will get 100 Juta - < 2 Miliyar

          – Van Tho
          Nov 23 '18 at 3:46







          Maybe because character <, the value of $cols->item(0)->nodeValue is empty. But I can make sure that this code got the right row by the table ID _Deposit_Rate_Display_Portlet_idrRate. If you change $table->getElementsByTagName('tr')[1]; to $table->getElementsByTagName('tr')[7]; , you will get 100 Juta - < 2 Miliyar

          – Van Tho
          Nov 23 '18 at 3:46















          I was tried $table->getElementsByTagName('tr')[7]; and I just get "100 Juta - " without "< 2 Miliyar". how to resolve this "<" character ?

          – coder
          Nov 23 '18 at 4:07





          I was tried $table->getElementsByTagName('tr')[7]; and I just get "100 Juta - " without "< 2 Miliyar". how to resolve this "<" character ?

          – coder
          Nov 23 '18 at 4:07













          I've tried several ways with Dom but none of it work. How about preg_match? replace Dom code with 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 />'; }

          – Van Tho
          Nov 23 '18 at 7:04







          I've tried several ways with Dom but none of it work. How about preg_match? replace Dom code with 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 />'; }

          – Van Tho
          Nov 23 '18 at 7:04















          Then you will get the result that you want. This way is bad but it works. If you want to get more data from that table, use preg_match_all instead of preg_match

          – Van Tho
          Nov 23 '18 at 7:07





          Then you will get the result that you want. This way is bad but it works. If you want to get more data from that table, use preg_match_all instead of preg_match

          – Van Tho
          Nov 23 '18 at 7:07


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440052%2fget-specific-target-or-data-on-table-in-other-website-using-curl-php%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'