3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Modified the cURL function to accept POST parameters and a cookiejar file // You will actually need to use a cookie jar because the cookie is not static // Using a cookie jar allows the server to change the cookie as needed and the changed cookie is sent back to the server. function request($url, $params=array(), $cookiejar="") { $ch = curl_init(); $curlOpts = array( CURLOPT_URL => $url, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true ); if (!empty($params)) { // If POST values are given, send that shit too $curlOpts[CURLOPT_POST] = true; $curlOpts[CURLOPT_POSTFIELDS] = $params; } if (!empty($cookiejar)) { if(!file_exists($cookiejar)){ echo 'Cookie file missing. please create it first.'; exit; }else if(!is_writable($cookiejar)){ echo 'Cookie file not writable. chmod it to 777.'; exit; } curl_setopt($ch, CURLOPT_COOKIEJAR, realpath($cookiejar)); curl_setopt($ch, CURLOPT_COOKIEFILE, realpath($cookiejar)); } curl_setopt_array($ch, $curlOpts); $answer = curl_exec($ch); // If there was an error, show it if (curl_error($ch)) die(curl_error($ch)); curl_close($ch); return $answer; } // The url you're trying to access $url = "http://store.steampowered.com/app/223470"; // The url that gives us the cookie $cookie_url = "http://store.steampowered.com/agecheck/app/223470/"; // The POST parameters that are sent to the server when requesting a cookie $params = array("ageDay"=>1, "ageMonth"=>"January", "ageYear"=>"1915", "snr"=>"1_agecheck_agecheck__age-gate"); // This request just give us a cookie. request($cookie_url, $params, "cookiejar"); // And this request is that page you need $html = request($url, array(), "cookiejar"); // Domdoc stuff that we already discussed $dom = new domDocument; libxml_use_internal_errors(true); $dom->loadHTML($html); $classname="game_description_snippet"; $finder = new DomXPath($dom); $spaner = $finder->query("//*[contains(@class, '$classname')]"); foreach ($spaner as $spane) { $mo = $spane->nodeValue; echo $mo; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 41
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/Ws7JP
function name:  (null)
number of ops:  43
compiled vars:  !0 = $url, !1 = $cookie_url, !2 = $params, !3 = $html, !4 = $dom, !5 = $classname, !6 = $finder, !7 = $spaner, !8 = $spane, !9 = $mo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fstore.steampowered.com%2Fapp%2F223470'
   44     1        ASSIGN                                                   !1, 'http%3A%2F%2Fstore.steampowered.com%2Fagecheck%2Fapp%2F223470%2F'
   47     2        ASSIGN                                                   !2, <array>
   50     3        INIT_FCALL                                               'request'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 'cookiejar'
          7        DO_FCALL                                      0          
   53     8        INIT_FCALL                                               'request'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 <array>
         11        SEND_VAL                                                 'cookiejar'
         12        DO_FCALL                                      0  $14     
         13        ASSIGN                                                   !3, $14
   56    14        NEW                                              $16     'domDocument'
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !4, $16
   57    17        INIT_FCALL                                               'libxml_use_internal_errors'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                                 
   58    20        INIT_METHOD_CALL                                         !4, 'loadHTML'
         21        SEND_VAR_EX                                              !3
         22        DO_FCALL                                      0          
   60    23        ASSIGN                                                   !5, 'game_description_snippet'
   61    24        NEW                                              $22     'DomXPath'
         25        SEND_VAR_EX                                              !4
         26        DO_FCALL                                      0          
         27        ASSIGN                                                   !6, $22
   62    28        INIT_METHOD_CALL                                         !6, 'query'
         29        ROPE_INIT                                     3  ~26     '%2F%2F%2A%5Bcontains%28%40class%2C+%27'
         30        ROPE_ADD                                      1  ~26     ~26, !5
         31        ROPE_END                                      2  ~25     ~26, '%27%29%5D'
         32        SEND_VAL_EX                                              ~25
         33        DO_FCALL                                      0  $28     
         34        ASSIGN                                                   !7, $28
   64    35      > FE_RESET_R                                       $30     !7, ->41
         36    > > FE_FETCH_R                                               $30, !8, ->41
   65    37    >   FETCH_OBJ_R                                      ~31     !8, 'nodeValue'
         38        ASSIGN                                                   !9, ~31
   66    39        ECHO                                                     !9
   64    40      > JMP                                                      ->36
         41    >   FE_FREE                                                  $30
   67    42      > RETURN                                                   1

Function request:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 62
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 78
Branch analysis from position: 74
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
Branch analysis from position: 26
filename:       /in/Ws7JP
function name:  request
number of ops:  83
compiled vars:  !0 = $url, !1 = $params, !2 = $cookiejar, !3 = $ch, !4 = $curlOpts, !5 = $answer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        RECV_INIT                                        !2      ''
    8     3        INIT_FCALL_BY_NAME                                       'curl_init'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !3, $6
   10     6        FETCH_CONSTANT                                   ~8      'CURLOPT_URL'
          7        INIT_ARRAY                                       ~9      !0, ~8
   11     8        FETCH_CONSTANT                                   ~10     'CURLOPT_SSL_VERIFYPEER'
   10     9        ADD_ARRAY_ELEMENT                                ~9      <false>, ~10
   12    10        FETCH_CONSTANT                                   ~11     'CURLOPT_SSL_VERIFYHOST'
   10    11        ADD_ARRAY_ELEMENT                                ~9      <false>, ~11
   13    12        FETCH_CONSTANT                                   ~12     'CURLOPT_RETURNTRANSFER'
   10    13        ADD_ARRAY_ELEMENT                                ~9      <true>, ~12
   14    14        FETCH_CONSTANT                                   ~13     'CURLOPT_FOLLOWLOCATION'
   10    15        ADD_ARRAY_ELEMENT                                ~9      <true>, ~13
    9    16        ASSIGN                                                   !4, ~9
   16    17        ISSET_ISEMPTY_CV                                 ~15     !1
         18        BOOL_NOT                                         ~16     ~15
         19      > JMPZ                                                     ~16, ->26
   18    20    >   FETCH_CONSTANT                                   ~17     'CURLOPT_POST'
         21        ASSIGN_DIM                                               !4, ~17
         22        OP_DATA                                                  <true>
   19    23        FETCH_CONSTANT                                   ~19     'CURLOPT_POSTFIELDS'
         24        ASSIGN_DIM                                               !4, ~19
         25        OP_DATA                                                  !1
   21    26    >   ISSET_ISEMPTY_CV                                 ~21     !2
         27        BOOL_NOT                                         ~22     ~21
         28      > JMPZ                                                     ~22, ->62
   23    29    >   INIT_FCALL                                               'file_exists'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $23     
         32        BOOL_NOT                                         ~24     $23
         33      > JMPZ                                                     ~24, ->37
   24    34    >   ECHO                                                     'Cookie+file+missing.+please+create+it+first.'
         35      > EXIT                                                     
         36*       JMP                                                      ->44
   25    37    >   INIT_FCALL                                               'is_writable'
         38        SEND_VAR                                                 !2
         39        DO_ICALL                                         $25     
         40        BOOL_NOT                                         ~26     $25
         41      > JMPZ                                                     ~26, ->44
   26    42    >   ECHO                                                     'Cookie+file+not+writable.+chmod+it+to+777.'
         43      > EXIT                                                     
   29    44    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         45        SEND_VAR_EX                                              !3
         46        FETCH_CONSTANT                                   ~27     'CURLOPT_COOKIEJAR'
         47        SEND_VAL_EX                                              ~27
         48        INIT_FCALL                                               'realpath'
         49        SEND_VAR                                                 !2
         50        DO_ICALL                                         $28     
         51        SEND_VAR_NO_REF_EX                                       $28
         52        DO_FCALL                                      0          
   30    53        INIT_FCALL_BY_NAME                                       'curl_setopt'
         54        SEND_VAR_EX                                              !3
         55        FETCH_CONSTANT                                   ~30     'CURLOPT_COOKIEFILE'
         56        SEND_VAL_EX                                              ~30
         57        INIT_FCALL                                               'realpath'
         58        SEND_VAR                                                 !2
         59        DO_ICALL                                         $31     
         60        SEND_VAR_NO_REF_EX                                       $31
         61        DO_FCALL                                      0          
   32    62    >   INIT_FCALL_BY_NAME                                       'curl_setopt_array'
         63        SEND_VAR_EX                                              !3
         64        SEND_VAR_EX                                              !4
         65        DO_FCALL                                      0          
   33    66        INIT_FCALL_BY_NAME                                       'curl_exec'
         67        SEND_VAR_EX                                              !3
         68        DO_FCALL                                      0  $34     
         69        ASSIGN                                                   !5, $34
   35    70        INIT_FCALL_BY_NAME                                       'curl_error'
         71        SEND_VAR_EX                                              !3
         72        DO_FCALL                                      0  $36     
         73      > JMPZ                                                     $36, ->78
         74    >   INIT_FCALL_BY_NAME                                       'curl_error'
         75        SEND_VAR_EX                                              !3
         76        DO_FCALL                                      0  $37     
         77      > EXIT                                                     $37
   36    78    >   INIT_FCALL_BY_NAME                                       'curl_close'
         79        SEND_VAR_EX                                              !3
         80        DO_FCALL                                      0          
   37    81      > RETURN                                                   !5
   38    82*     > RETURN                                                   null

End of function request

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.94 ms | 1415 KiB | 23 Q