Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2.  
  3. if(file_exists('pseudos.txt') && filesize('pseudos.txt') > 1048576)
  4.     exit;
  5.  
  6. $urlbasetopic = "http://www.jeuxvideo.com";
  7. $urlfor = "http://www.jeuxvideo.com/forums/0-51-0-1-0-1-0-blabla-18-25-ans.htm";
  8.  
  9. $res = curl_get($urlfor);
  10. if(!$res)
  11.     exit;
  12.  
  13. preg_match_all('/\<a class\=\"lien\-jv\ topic\-title\"\ href\=\"([^"]*)\"/',$res,$matches);
  14.  
  15. if(empty($matches[1]))
  16.     exit;
  17.  
  18. $pseudos = file_exists('pseudos.txt') ? file('pseudos.txt',FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : [];
  19.  
  20. foreach($matches[1] as $url)
  21.     {
  22.     $res = curl_get($urlbasetopic . $url);
  23.     preg_match_all('/\<span\ class=\"[^\"]*bloc\-pseudo\-msg[^\"]*\"[^>]*\>([^\<]*)\<\/span\>/',$res,$matches);
  24.     if(empty($matches[1]))
  25.         exit;
  26.     foreach($matches[1] as $span_pseudo)
  27.         {
  28.         $pseudo = trim($span_pseudo);
  29.         $pseudos[] = $pseudo;
  30.         }
  31.     }
  32.    
  33. $pseudos = array_unique($pseudos);
  34.  
  35. $f = fopen('pseudos.txt','w');
  36. foreach($pseudos as $pseudo)
  37.     {
  38.     fwrite($f,$pseudo.PHP_EOL);
  39.     }  
  40.    
  41.  
  42. function curl_get($url)
  43.     {
  44.     $req = curl_init($url);
  45.     curl_setopt($req,CURLOPT_FAILONERROR,true);
  46.     curl_setopt($req,CURLOPT_RETURNTRANSFER,true);
  47.     return curl_exec($req);
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement