PHP - proxy checker multi-threaded












0















I already made my personal single thread proxy checker using php,but I couldnt make it multi-thread,some days ago,I found one checker using multi-thread on github,can someone help to change it to save the good proxies into a file (ip:port format)?



https://raw.githubusercontent.com/samuel-allan/FastProxyChecker/master/checker.php



What i have tried:



original line 91:
echo json_encode($arr);

changed to:

$json = json_decode($arr);
$good_proxie = $json['arr']['result']['proxy']['ip'];
echo "$good_proxie";









share|improve this question





























    0















    I already made my personal single thread proxy checker using php,but I couldnt make it multi-thread,some days ago,I found one checker using multi-thread on github,can someone help to change it to save the good proxies into a file (ip:port format)?



    https://raw.githubusercontent.com/samuel-allan/FastProxyChecker/master/checker.php



    What i have tried:



    original line 91:
    echo json_encode($arr);

    changed to:

    $json = json_decode($arr);
    $good_proxie = $json['arr']['result']['proxy']['ip'];
    echo "$good_proxie";









    share|improve this question



























      0












      0








      0








      I already made my personal single thread proxy checker using php,but I couldnt make it multi-thread,some days ago,I found one checker using multi-thread on github,can someone help to change it to save the good proxies into a file (ip:port format)?



      https://raw.githubusercontent.com/samuel-allan/FastProxyChecker/master/checker.php



      What i have tried:



      original line 91:
      echo json_encode($arr);

      changed to:

      $json = json_decode($arr);
      $good_proxie = $json['arr']['result']['proxy']['ip'];
      echo "$good_proxie";









      share|improve this question
















      I already made my personal single thread proxy checker using php,but I couldnt make it multi-thread,some days ago,I found one checker using multi-thread on github,can someone help to change it to save the good proxies into a file (ip:port format)?



      https://raw.githubusercontent.com/samuel-allan/FastProxyChecker/master/checker.php



      What i have tried:



      original line 91:
      echo json_encode($arr);

      changed to:

      $json = json_decode($arr);
      $good_proxie = $json['arr']['result']['proxy']['ip'];
      echo "$good_proxie";






      php multithreading proxy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 12:14







      eduard trionleon

















      asked Nov 21 '18 at 12:03









      eduard trionleoneduard trionleon

      102




      102
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I did not checked it, but think it'll work ^_^



          function CheckMultiProxy($proxies, $timeout, $proxy_type)
          {
          $data = array();
          foreach($proxies as $proxy)
          {
          $parts = explode(':', trim($proxy));
          $url = strtok(curPageURL(),'?');
          $data = $url . '?ip=' . $parts[0] . "&port=" . $parts[1] . "&timeout=" . $timeout . "&proxy_type=" . $proxy_type;
          }
          $results = multiRequest($data);
          $holder = array();
          foreach($results as $result)
          {

          $holder = json_decode($result, true)["result"];
          }
          $arr = array("results" => $holder);

          foreach ($arr['results'] as $proxy) {
          if ($proxy['success']) {
          file_put_contents('YOUR_FILE_HERE', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].' '.$proxy['proxy']['type'].PHP_EOL, FILE_APPEND);
          }
          }

          echo json_encode($arr);
          }





          share|improve this answer


























          • Hello brother , I tried your code but it gives me error "{"results":[null,null,null,null..............." , and no file is created (I set the file name to good-proxies.txt)

            – eduard trionleon
            Nov 21 '18 at 16:14











          • can you please give a var_dump of one $proxy in the foreach - so I'll improve it: just put var_dump($proxy) before the file_put_contents - and give the result to me

            – myxaxa
            Nov 21 '18 at 16:20













          • the "var_dump($proxy)" returns: "NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL.........) and the original script shows: "{"results":[{"success":true,"proxy":{"ip":"103.21.160.156","port":"9999","speed":3833,"type":"http(s)"}},{"success":true,""

            – eduard trionleon
            Nov 21 '18 at 17:59











          • can you check it again - I've updated the post:)

            – myxaxa
            Nov 22 '18 at 8:35






          • 1





            I just have to fix a little error in your last script,i changed this part: foreach ($arr['results'] as $proxy) { ***if ($proxy['success']) {*** file_put_contents('working.txt', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].PHP_EOL, FILE_APPEND); } } Now the script is working 100% , thank you very much dude.

            – eduard trionleon
            Nov 22 '18 at 17:01













          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%2f53411629%2fphp-proxy-checker-multi-threaded%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














          I did not checked it, but think it'll work ^_^



          function CheckMultiProxy($proxies, $timeout, $proxy_type)
          {
          $data = array();
          foreach($proxies as $proxy)
          {
          $parts = explode(':', trim($proxy));
          $url = strtok(curPageURL(),'?');
          $data = $url . '?ip=' . $parts[0] . "&port=" . $parts[1] . "&timeout=" . $timeout . "&proxy_type=" . $proxy_type;
          }
          $results = multiRequest($data);
          $holder = array();
          foreach($results as $result)
          {

          $holder = json_decode($result, true)["result"];
          }
          $arr = array("results" => $holder);

          foreach ($arr['results'] as $proxy) {
          if ($proxy['success']) {
          file_put_contents('YOUR_FILE_HERE', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].' '.$proxy['proxy']['type'].PHP_EOL, FILE_APPEND);
          }
          }

          echo json_encode($arr);
          }





          share|improve this answer


























          • Hello brother , I tried your code but it gives me error "{"results":[null,null,null,null..............." , and no file is created (I set the file name to good-proxies.txt)

            – eduard trionleon
            Nov 21 '18 at 16:14











          • can you please give a var_dump of one $proxy in the foreach - so I'll improve it: just put var_dump($proxy) before the file_put_contents - and give the result to me

            – myxaxa
            Nov 21 '18 at 16:20













          • the "var_dump($proxy)" returns: "NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL.........) and the original script shows: "{"results":[{"success":true,"proxy":{"ip":"103.21.160.156","port":"9999","speed":3833,"type":"http(s)"}},{"success":true,""

            – eduard trionleon
            Nov 21 '18 at 17:59











          • can you check it again - I've updated the post:)

            – myxaxa
            Nov 22 '18 at 8:35






          • 1





            I just have to fix a little error in your last script,i changed this part: foreach ($arr['results'] as $proxy) { ***if ($proxy['success']) {*** file_put_contents('working.txt', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].PHP_EOL, FILE_APPEND); } } Now the script is working 100% , thank you very much dude.

            – eduard trionleon
            Nov 22 '18 at 17:01


















          0














          I did not checked it, but think it'll work ^_^



          function CheckMultiProxy($proxies, $timeout, $proxy_type)
          {
          $data = array();
          foreach($proxies as $proxy)
          {
          $parts = explode(':', trim($proxy));
          $url = strtok(curPageURL(),'?');
          $data = $url . '?ip=' . $parts[0] . "&port=" . $parts[1] . "&timeout=" . $timeout . "&proxy_type=" . $proxy_type;
          }
          $results = multiRequest($data);
          $holder = array();
          foreach($results as $result)
          {

          $holder = json_decode($result, true)["result"];
          }
          $arr = array("results" => $holder);

          foreach ($arr['results'] as $proxy) {
          if ($proxy['success']) {
          file_put_contents('YOUR_FILE_HERE', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].' '.$proxy['proxy']['type'].PHP_EOL, FILE_APPEND);
          }
          }

          echo json_encode($arr);
          }





          share|improve this answer


























          • Hello brother , I tried your code but it gives me error "{"results":[null,null,null,null..............." , and no file is created (I set the file name to good-proxies.txt)

            – eduard trionleon
            Nov 21 '18 at 16:14











          • can you please give a var_dump of one $proxy in the foreach - so I'll improve it: just put var_dump($proxy) before the file_put_contents - and give the result to me

            – myxaxa
            Nov 21 '18 at 16:20













          • the "var_dump($proxy)" returns: "NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL.........) and the original script shows: "{"results":[{"success":true,"proxy":{"ip":"103.21.160.156","port":"9999","speed":3833,"type":"http(s)"}},{"success":true,""

            – eduard trionleon
            Nov 21 '18 at 17:59











          • can you check it again - I've updated the post:)

            – myxaxa
            Nov 22 '18 at 8:35






          • 1





            I just have to fix a little error in your last script,i changed this part: foreach ($arr['results'] as $proxy) { ***if ($proxy['success']) {*** file_put_contents('working.txt', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].PHP_EOL, FILE_APPEND); } } Now the script is working 100% , thank you very much dude.

            – eduard trionleon
            Nov 22 '18 at 17:01
















          0












          0








          0







          I did not checked it, but think it'll work ^_^



          function CheckMultiProxy($proxies, $timeout, $proxy_type)
          {
          $data = array();
          foreach($proxies as $proxy)
          {
          $parts = explode(':', trim($proxy));
          $url = strtok(curPageURL(),'?');
          $data = $url . '?ip=' . $parts[0] . "&port=" . $parts[1] . "&timeout=" . $timeout . "&proxy_type=" . $proxy_type;
          }
          $results = multiRequest($data);
          $holder = array();
          foreach($results as $result)
          {

          $holder = json_decode($result, true)["result"];
          }
          $arr = array("results" => $holder);

          foreach ($arr['results'] as $proxy) {
          if ($proxy['success']) {
          file_put_contents('YOUR_FILE_HERE', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].' '.$proxy['proxy']['type'].PHP_EOL, FILE_APPEND);
          }
          }

          echo json_encode($arr);
          }





          share|improve this answer















          I did not checked it, but think it'll work ^_^



          function CheckMultiProxy($proxies, $timeout, $proxy_type)
          {
          $data = array();
          foreach($proxies as $proxy)
          {
          $parts = explode(':', trim($proxy));
          $url = strtok(curPageURL(),'?');
          $data = $url . '?ip=' . $parts[0] . "&port=" . $parts[1] . "&timeout=" . $timeout . "&proxy_type=" . $proxy_type;
          }
          $results = multiRequest($data);
          $holder = array();
          foreach($results as $result)
          {

          $holder = json_decode($result, true)["result"];
          }
          $arr = array("results" => $holder);

          foreach ($arr['results'] as $proxy) {
          if ($proxy['success']) {
          file_put_contents('YOUR_FILE_HERE', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].' '.$proxy['proxy']['type'].PHP_EOL, FILE_APPEND);
          }
          }

          echo json_encode($arr);
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 17:02

























          answered Nov 21 '18 at 13:38









          myxaxamyxaxa

          62036




          62036













          • Hello brother , I tried your code but it gives me error "{"results":[null,null,null,null..............." , and no file is created (I set the file name to good-proxies.txt)

            – eduard trionleon
            Nov 21 '18 at 16:14











          • can you please give a var_dump of one $proxy in the foreach - so I'll improve it: just put var_dump($proxy) before the file_put_contents - and give the result to me

            – myxaxa
            Nov 21 '18 at 16:20













          • the "var_dump($proxy)" returns: "NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL.........) and the original script shows: "{"results":[{"success":true,"proxy":{"ip":"103.21.160.156","port":"9999","speed":3833,"type":"http(s)"}},{"success":true,""

            – eduard trionleon
            Nov 21 '18 at 17:59











          • can you check it again - I've updated the post:)

            – myxaxa
            Nov 22 '18 at 8:35






          • 1





            I just have to fix a little error in your last script,i changed this part: foreach ($arr['results'] as $proxy) { ***if ($proxy['success']) {*** file_put_contents('working.txt', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].PHP_EOL, FILE_APPEND); } } Now the script is working 100% , thank you very much dude.

            – eduard trionleon
            Nov 22 '18 at 17:01





















          • Hello brother , I tried your code but it gives me error "{"results":[null,null,null,null..............." , and no file is created (I set the file name to good-proxies.txt)

            – eduard trionleon
            Nov 21 '18 at 16:14











          • can you please give a var_dump of one $proxy in the foreach - so I'll improve it: just put var_dump($proxy) before the file_put_contents - and give the result to me

            – myxaxa
            Nov 21 '18 at 16:20













          • the "var_dump($proxy)" returns: "NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL.........) and the original script shows: "{"results":[{"success":true,"proxy":{"ip":"103.21.160.156","port":"9999","speed":3833,"type":"http(s)"}},{"success":true,""

            – eduard trionleon
            Nov 21 '18 at 17:59











          • can you check it again - I've updated the post:)

            – myxaxa
            Nov 22 '18 at 8:35






          • 1





            I just have to fix a little error in your last script,i changed this part: foreach ($arr['results'] as $proxy) { ***if ($proxy['success']) {*** file_put_contents('working.txt', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].PHP_EOL, FILE_APPEND); } } Now the script is working 100% , thank you very much dude.

            – eduard trionleon
            Nov 22 '18 at 17:01



















          Hello brother , I tried your code but it gives me error "{"results":[null,null,null,null..............." , and no file is created (I set the file name to good-proxies.txt)

          – eduard trionleon
          Nov 21 '18 at 16:14





          Hello brother , I tried your code but it gives me error "{"results":[null,null,null,null..............." , and no file is created (I set the file name to good-proxies.txt)

          – eduard trionleon
          Nov 21 '18 at 16:14













          can you please give a var_dump of one $proxy in the foreach - so I'll improve it: just put var_dump($proxy) before the file_put_contents - and give the result to me

          – myxaxa
          Nov 21 '18 at 16:20







          can you please give a var_dump of one $proxy in the foreach - so I'll improve it: just put var_dump($proxy) before the file_put_contents - and give the result to me

          – myxaxa
          Nov 21 '18 at 16:20















          the "var_dump($proxy)" returns: "NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL.........) and the original script shows: "{"results":[{"success":true,"proxy":{"ip":"103.21.160.156","port":"9999","speed":3833,"type":"http(s)"}},{"success":true,""

          – eduard trionleon
          Nov 21 '18 at 17:59





          the "var_dump($proxy)" returns: "NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL.........) and the original script shows: "{"results":[{"success":true,"proxy":{"ip":"103.21.160.156","port":"9999","speed":3833,"type":"http(s)"}},{"success":true,""

          – eduard trionleon
          Nov 21 '18 at 17:59













          can you check it again - I've updated the post:)

          – myxaxa
          Nov 22 '18 at 8:35





          can you check it again - I've updated the post:)

          – myxaxa
          Nov 22 '18 at 8:35




          1




          1





          I just have to fix a little error in your last script,i changed this part: foreach ($arr['results'] as $proxy) { ***if ($proxy['success']) {*** file_put_contents('working.txt', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].PHP_EOL, FILE_APPEND); } } Now the script is working 100% , thank you very much dude.

          – eduard trionleon
          Nov 22 '18 at 17:01







          I just have to fix a little error in your last script,i changed this part: foreach ($arr['results'] as $proxy) { ***if ($proxy['success']) {*** file_put_contents('working.txt', $proxy['proxy']['ip'].':'.$proxy['proxy']['port'].PHP_EOL, FILE_APPEND); } } Now the script is working 100% , thank you very much dude.

          – eduard trionleon
          Nov 22 '18 at 17:01






















          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%2f53411629%2fphp-proxy-checker-multi-threaded%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

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          How to fix TextFormField cause rebuild widget in Flutter