fork download
  1. <?php
  2.  
  3. // o HTML que recolheste
  4. $html = '<html>
  5. <head></head>
  6. <body>
  7. <a href="https://w...content-available-to-author-only...e.com/user.asp?ref=fvFCF9D8N4Ak">bubu</a>
  8. <a href="https://w...content-available-to-author-only...e.com/checkout.asp?ref=fvFDGND2MYQ">bubu</a>
  9. <a href="https://w...content-available-to-author-only...e.com/user.asp?ref=fvFCF9D8N4Ak">bubu</a>
  10. </body>
  11. </html>';
  12.  
  13. // Instanciar o DOMDocument
  14. $dom = new DOMDocument;
  15.  
  16. // Carregar o HTML recolhido para o DOMDocument
  17. @$dom->loadHTML($html);
  18.  
  19. // Percorrer o DOM e por cada tag 'a' encontrada
  20. foreach ($dom->getElementsByTagName('a') as $tag) {
  21.  
  22. // apanhar o valor do atributo 'href'
  23. $href = $tag->getAttribute('href');
  24.  
  25. // se não estiver vazio
  26. if (!empty($href) && strpos($href, "checkout.asp?ref=") !== FALSE) {
  27.  
  28. // guardar a query string numa variável
  29. echo $queryString = parse_url($href, PHP_URL_QUERY); // Resultado: ref=fvFCF9D8N4Ak
  30. }
  31. }
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
ref=fvFDGND2MYQ