Php Web Crawler Click












0















<?php
include_once('simple_html_dom.php');

$veri = file_get_html("http://apps.istanbulsaglik.gov.tr/Eczane");


preg_match_all('@<a href="(.*?)" class="ilce-link" data-value="(.*?)"
data-ilcename="(.*?)" data-title="(.*?)" id="ilce" title="(.*?)"><i
class="fa fa-dot-circle-o"></i>(.*?)</a>@si',$veri,$baslik);
$length = count($baslik[4]);

for ($i = 0; $i < $length; $i++) {
echo $baslik[4][$i];
echo "</br>";
}

preg_match_all('@<table class="table ilce-nobet-detay" id="ilce-nobet-detay">(.*?)</table>@si',$veri,$adres);

echo $adres[1][1];
?>


In this link;
http://apps.istanbulsaglik.gov.tr/Eczane I can not get the right side elements that will be listed under "Eczaneler".



Because I need to click any of left side elements then, I can see them. What I want to do is getting that elements in my web crawler.
The main problem is how can I make my crawler click? without clicking I can not see any data.
If I can make it click, then I can take the data from html source. If not my crawler will always return empty.










share|improve this question



























    0















    <?php
    include_once('simple_html_dom.php');

    $veri = file_get_html("http://apps.istanbulsaglik.gov.tr/Eczane");


    preg_match_all('@<a href="(.*?)" class="ilce-link" data-value="(.*?)"
    data-ilcename="(.*?)" data-title="(.*?)" id="ilce" title="(.*?)"><i
    class="fa fa-dot-circle-o"></i>(.*?)</a>@si',$veri,$baslik);
    $length = count($baslik[4]);

    for ($i = 0; $i < $length; $i++) {
    echo $baslik[4][$i];
    echo "</br>";
    }

    preg_match_all('@<table class="table ilce-nobet-detay" id="ilce-nobet-detay">(.*?)</table>@si',$veri,$adres);

    echo $adres[1][1];
    ?>


    In this link;
    http://apps.istanbulsaglik.gov.tr/Eczane I can not get the right side elements that will be listed under "Eczaneler".



    Because I need to click any of left side elements then, I can see them. What I want to do is getting that elements in my web crawler.
    The main problem is how can I make my crawler click? without clicking I can not see any data.
    If I can make it click, then I can take the data from html source. If not my crawler will always return empty.










    share|improve this question

























      0












      0








      0








      <?php
      include_once('simple_html_dom.php');

      $veri = file_get_html("http://apps.istanbulsaglik.gov.tr/Eczane");


      preg_match_all('@<a href="(.*?)" class="ilce-link" data-value="(.*?)"
      data-ilcename="(.*?)" data-title="(.*?)" id="ilce" title="(.*?)"><i
      class="fa fa-dot-circle-o"></i>(.*?)</a>@si',$veri,$baslik);
      $length = count($baslik[4]);

      for ($i = 0; $i < $length; $i++) {
      echo $baslik[4][$i];
      echo "</br>";
      }

      preg_match_all('@<table class="table ilce-nobet-detay" id="ilce-nobet-detay">(.*?)</table>@si',$veri,$adres);

      echo $adres[1][1];
      ?>


      In this link;
      http://apps.istanbulsaglik.gov.tr/Eczane I can not get the right side elements that will be listed under "Eczaneler".



      Because I need to click any of left side elements then, I can see them. What I want to do is getting that elements in my web crawler.
      The main problem is how can I make my crawler click? without clicking I can not see any data.
      If I can make it click, then I can take the data from html source. If not my crawler will always return empty.










      share|improve this question














      <?php
      include_once('simple_html_dom.php');

      $veri = file_get_html("http://apps.istanbulsaglik.gov.tr/Eczane");


      preg_match_all('@<a href="(.*?)" class="ilce-link" data-value="(.*?)"
      data-ilcename="(.*?)" data-title="(.*?)" id="ilce" title="(.*?)"><i
      class="fa fa-dot-circle-o"></i>(.*?)</a>@si',$veri,$baslik);
      $length = count($baslik[4]);

      for ($i = 0; $i < $length; $i++) {
      echo $baslik[4][$i];
      echo "</br>";
      }

      preg_match_all('@<table class="table ilce-nobet-detay" id="ilce-nobet-detay">(.*?)</table>@si',$veri,$adres);

      echo $adres[1][1];
      ?>


      In this link;
      http://apps.istanbulsaglik.gov.tr/Eczane I can not get the right side elements that will be listed under "Eczaneler".



      Because I need to click any of left side elements then, I can see them. What I want to do is getting that elements in my web crawler.
      The main problem is how can I make my crawler click? without clicking I can not see any data.
      If I can make it click, then I can take the data from html source. If not my crawler will always return empty.







      javascript php jquery html






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 6 '17 at 1:28









      Ahmet Aziz BeşliAhmet Aziz Beşli

      117211




      117211
























          1 Answer
          1






          active

          oldest

          votes


















          2














          If you use any browser's inspector on http://apps.istanbulsaglik.gov.tr/Eczane link, you will see that each link in İlçeler column has a data-value and binded to a click event:



          the page Javascript code:



          $(function () {
          $(".ilce-link").on("click", function (parameters) {
          var title = $(this).data("title").toUpperCase();
          var id = $(this).data("value");
          var request = $.ajax({
          url: "/Eczane/nobetci",
          method: "POST",
          data: { "id": id, "token": "aa416735d12fd44b" },
          dataType: "html"
          });
          request.done(function (data) {
          $("#nobet").empty(" ");
          $("#nobet").html('<i class="fa fa-spinner fa-spin"></i>');
          $("#nobet").html(data);
          document.title = "06-11-2017 TARİHİNDEKİ " + title + " İLEÇSİNDEKİ NÖBETÇİ ECZANE LİSTESİ";
          });
          });
          });


          This code means that when you click on any link in the left column, the script will create a post request by AJAX to this url: http://apps.istanbulsaglik.gov.tr/Eczane/nobetci with an id and a token.



          So the idea is to directly use this url and post data, you can get the id from the link element and the token from the js code on the first page, and then use CURL PHP to post these data.



          Here is an example using CURL post:



          $ch = curl_init();

          curl_setopt($ch, CURLOPT_URL,"http://apps.istanbulsaglik.gov.tr/Eczane/nobetci");
          curl_setopt($ch, CURLOPT_POST, 1);
          // you can use preg_match_all to retrieve the id and the token from the first page
          curl_setopt($ch, CURLOPT_POSTFIELDS, "id=$id&token=$token");

          $output = curl_exec ($ch);

          curl_close ($ch);





          share|improve this answer
























          • What I understand from your answer is, I will find id and the token with preg_match_all and i will initialize them into $id and $token. What I wonder is what will this $output variable give me ?

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:28











          • I think, I don't need token, because it's automatically generated in script. But when I call the Curl function only with "id" it gives me runtime error as you can see when you directly enter the link = apps.istanbulsaglik.gov.tr/Eczane/nobetci

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:59













          • You have to create 2 Curl requests, the first one to retrieve the token from the page http://apps.istanbulsaglik.gov.tr/Eczane and the second to make a post request to http://apps.istanbulsaglik.gov.tr/Eczane/nobetci using the token that you already take from the first page

            – YouneL
            Nov 6 '17 at 11:14













          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%2f47128499%2fphp-web-crawler-click%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









          2














          If you use any browser's inspector on http://apps.istanbulsaglik.gov.tr/Eczane link, you will see that each link in İlçeler column has a data-value and binded to a click event:



          the page Javascript code:



          $(function () {
          $(".ilce-link").on("click", function (parameters) {
          var title = $(this).data("title").toUpperCase();
          var id = $(this).data("value");
          var request = $.ajax({
          url: "/Eczane/nobetci",
          method: "POST",
          data: { "id": id, "token": "aa416735d12fd44b" },
          dataType: "html"
          });
          request.done(function (data) {
          $("#nobet").empty(" ");
          $("#nobet").html('<i class="fa fa-spinner fa-spin"></i>');
          $("#nobet").html(data);
          document.title = "06-11-2017 TARİHİNDEKİ " + title + " İLEÇSİNDEKİ NÖBETÇİ ECZANE LİSTESİ";
          });
          });
          });


          This code means that when you click on any link in the left column, the script will create a post request by AJAX to this url: http://apps.istanbulsaglik.gov.tr/Eczane/nobetci with an id and a token.



          So the idea is to directly use this url and post data, you can get the id from the link element and the token from the js code on the first page, and then use CURL PHP to post these data.



          Here is an example using CURL post:



          $ch = curl_init();

          curl_setopt($ch, CURLOPT_URL,"http://apps.istanbulsaglik.gov.tr/Eczane/nobetci");
          curl_setopt($ch, CURLOPT_POST, 1);
          // you can use preg_match_all to retrieve the id and the token from the first page
          curl_setopt($ch, CURLOPT_POSTFIELDS, "id=$id&token=$token");

          $output = curl_exec ($ch);

          curl_close ($ch);





          share|improve this answer
























          • What I understand from your answer is, I will find id and the token with preg_match_all and i will initialize them into $id and $token. What I wonder is what will this $output variable give me ?

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:28











          • I think, I don't need token, because it's automatically generated in script. But when I call the Curl function only with "id" it gives me runtime error as you can see when you directly enter the link = apps.istanbulsaglik.gov.tr/Eczane/nobetci

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:59













          • You have to create 2 Curl requests, the first one to retrieve the token from the page http://apps.istanbulsaglik.gov.tr/Eczane and the second to make a post request to http://apps.istanbulsaglik.gov.tr/Eczane/nobetci using the token that you already take from the first page

            – YouneL
            Nov 6 '17 at 11:14


















          2














          If you use any browser's inspector on http://apps.istanbulsaglik.gov.tr/Eczane link, you will see that each link in İlçeler column has a data-value and binded to a click event:



          the page Javascript code:



          $(function () {
          $(".ilce-link").on("click", function (parameters) {
          var title = $(this).data("title").toUpperCase();
          var id = $(this).data("value");
          var request = $.ajax({
          url: "/Eczane/nobetci",
          method: "POST",
          data: { "id": id, "token": "aa416735d12fd44b" },
          dataType: "html"
          });
          request.done(function (data) {
          $("#nobet").empty(" ");
          $("#nobet").html('<i class="fa fa-spinner fa-spin"></i>');
          $("#nobet").html(data);
          document.title = "06-11-2017 TARİHİNDEKİ " + title + " İLEÇSİNDEKİ NÖBETÇİ ECZANE LİSTESİ";
          });
          });
          });


          This code means that when you click on any link in the left column, the script will create a post request by AJAX to this url: http://apps.istanbulsaglik.gov.tr/Eczane/nobetci with an id and a token.



          So the idea is to directly use this url and post data, you can get the id from the link element and the token from the js code on the first page, and then use CURL PHP to post these data.



          Here is an example using CURL post:



          $ch = curl_init();

          curl_setopt($ch, CURLOPT_URL,"http://apps.istanbulsaglik.gov.tr/Eczane/nobetci");
          curl_setopt($ch, CURLOPT_POST, 1);
          // you can use preg_match_all to retrieve the id and the token from the first page
          curl_setopt($ch, CURLOPT_POSTFIELDS, "id=$id&token=$token");

          $output = curl_exec ($ch);

          curl_close ($ch);





          share|improve this answer
























          • What I understand from your answer is, I will find id and the token with preg_match_all and i will initialize them into $id and $token. What I wonder is what will this $output variable give me ?

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:28











          • I think, I don't need token, because it's automatically generated in script. But when I call the Curl function only with "id" it gives me runtime error as you can see when you directly enter the link = apps.istanbulsaglik.gov.tr/Eczane/nobetci

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:59













          • You have to create 2 Curl requests, the first one to retrieve the token from the page http://apps.istanbulsaglik.gov.tr/Eczane and the second to make a post request to http://apps.istanbulsaglik.gov.tr/Eczane/nobetci using the token that you already take from the first page

            – YouneL
            Nov 6 '17 at 11:14
















          2












          2








          2







          If you use any browser's inspector on http://apps.istanbulsaglik.gov.tr/Eczane link, you will see that each link in İlçeler column has a data-value and binded to a click event:



          the page Javascript code:



          $(function () {
          $(".ilce-link").on("click", function (parameters) {
          var title = $(this).data("title").toUpperCase();
          var id = $(this).data("value");
          var request = $.ajax({
          url: "/Eczane/nobetci",
          method: "POST",
          data: { "id": id, "token": "aa416735d12fd44b" },
          dataType: "html"
          });
          request.done(function (data) {
          $("#nobet").empty(" ");
          $("#nobet").html('<i class="fa fa-spinner fa-spin"></i>');
          $("#nobet").html(data);
          document.title = "06-11-2017 TARİHİNDEKİ " + title + " İLEÇSİNDEKİ NÖBETÇİ ECZANE LİSTESİ";
          });
          });
          });


          This code means that when you click on any link in the left column, the script will create a post request by AJAX to this url: http://apps.istanbulsaglik.gov.tr/Eczane/nobetci with an id and a token.



          So the idea is to directly use this url and post data, you can get the id from the link element and the token from the js code on the first page, and then use CURL PHP to post these data.



          Here is an example using CURL post:



          $ch = curl_init();

          curl_setopt($ch, CURLOPT_URL,"http://apps.istanbulsaglik.gov.tr/Eczane/nobetci");
          curl_setopt($ch, CURLOPT_POST, 1);
          // you can use preg_match_all to retrieve the id and the token from the first page
          curl_setopt($ch, CURLOPT_POSTFIELDS, "id=$id&token=$token");

          $output = curl_exec ($ch);

          curl_close ($ch);





          share|improve this answer













          If you use any browser's inspector on http://apps.istanbulsaglik.gov.tr/Eczane link, you will see that each link in İlçeler column has a data-value and binded to a click event:



          the page Javascript code:



          $(function () {
          $(".ilce-link").on("click", function (parameters) {
          var title = $(this).data("title").toUpperCase();
          var id = $(this).data("value");
          var request = $.ajax({
          url: "/Eczane/nobetci",
          method: "POST",
          data: { "id": id, "token": "aa416735d12fd44b" },
          dataType: "html"
          });
          request.done(function (data) {
          $("#nobet").empty(" ");
          $("#nobet").html('<i class="fa fa-spinner fa-spin"></i>');
          $("#nobet").html(data);
          document.title = "06-11-2017 TARİHİNDEKİ " + title + " İLEÇSİNDEKİ NÖBETÇİ ECZANE LİSTESİ";
          });
          });
          });


          This code means that when you click on any link in the left column, the script will create a post request by AJAX to this url: http://apps.istanbulsaglik.gov.tr/Eczane/nobetci with an id and a token.



          So the idea is to directly use this url and post data, you can get the id from the link element and the token from the js code on the first page, and then use CURL PHP to post these data.



          Here is an example using CURL post:



          $ch = curl_init();

          curl_setopt($ch, CURLOPT_URL,"http://apps.istanbulsaglik.gov.tr/Eczane/nobetci");
          curl_setopt($ch, CURLOPT_POST, 1);
          // you can use preg_match_all to retrieve the id and the token from the first page
          curl_setopt($ch, CURLOPT_POSTFIELDS, "id=$id&token=$token");

          $output = curl_exec ($ch);

          curl_close ($ch);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 6 '17 at 2:12









          YouneLYouneL

          5,46421133




          5,46421133













          • What I understand from your answer is, I will find id and the token with preg_match_all and i will initialize them into $id and $token. What I wonder is what will this $output variable give me ?

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:28











          • I think, I don't need token, because it's automatically generated in script. But when I call the Curl function only with "id" it gives me runtime error as you can see when you directly enter the link = apps.istanbulsaglik.gov.tr/Eczane/nobetci

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:59













          • You have to create 2 Curl requests, the first one to retrieve the token from the page http://apps.istanbulsaglik.gov.tr/Eczane and the second to make a post request to http://apps.istanbulsaglik.gov.tr/Eczane/nobetci using the token that you already take from the first page

            – YouneL
            Nov 6 '17 at 11:14





















          • What I understand from your answer is, I will find id and the token with preg_match_all and i will initialize them into $id and $token. What I wonder is what will this $output variable give me ?

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:28











          • I think, I don't need token, because it's automatically generated in script. But when I call the Curl function only with "id" it gives me runtime error as you can see when you directly enter the link = apps.istanbulsaglik.gov.tr/Eczane/nobetci

            – Ahmet Aziz Beşli
            Nov 6 '17 at 2:59













          • You have to create 2 Curl requests, the first one to retrieve the token from the page http://apps.istanbulsaglik.gov.tr/Eczane and the second to make a post request to http://apps.istanbulsaglik.gov.tr/Eczane/nobetci using the token that you already take from the first page

            – YouneL
            Nov 6 '17 at 11:14



















          What I understand from your answer is, I will find id and the token with preg_match_all and i will initialize them into $id and $token. What I wonder is what will this $output variable give me ?

          – Ahmet Aziz Beşli
          Nov 6 '17 at 2:28





          What I understand from your answer is, I will find id and the token with preg_match_all and i will initialize them into $id and $token. What I wonder is what will this $output variable give me ?

          – Ahmet Aziz Beşli
          Nov 6 '17 at 2:28













          I think, I don't need token, because it's automatically generated in script. But when I call the Curl function only with "id" it gives me runtime error as you can see when you directly enter the link = apps.istanbulsaglik.gov.tr/Eczane/nobetci

          – Ahmet Aziz Beşli
          Nov 6 '17 at 2:59







          I think, I don't need token, because it's automatically generated in script. But when I call the Curl function only with "id" it gives me runtime error as you can see when you directly enter the link = apps.istanbulsaglik.gov.tr/Eczane/nobetci

          – Ahmet Aziz Beşli
          Nov 6 '17 at 2:59















          You have to create 2 Curl requests, the first one to retrieve the token from the page http://apps.istanbulsaglik.gov.tr/Eczane and the second to make a post request to http://apps.istanbulsaglik.gov.tr/Eczane/nobetci using the token that you already take from the first page

          – YouneL
          Nov 6 '17 at 11:14







          You have to create 2 Curl requests, the first one to retrieve the token from the page http://apps.istanbulsaglik.gov.tr/Eczane and the second to make a post request to http://apps.istanbulsaglik.gov.tr/Eczane/nobetci using the token that you already take from the first page

          – YouneL
          Nov 6 '17 at 11:14






















          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%2f47128499%2fphp-web-crawler-click%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

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks