Advertisement
NokitaKaze

Качаем AniDB

Jan 20th, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.14 KB | None | 0 0
  1. #!/usr/local/bin/php
  2. <?php
  3.  srand();
  4.  function is_load_complete(){
  5.   for ($page=1;$page<=12000;$page++){
  6.    if (!file_exists('dmp-'.$page.'.html')){return false;}
  7.   }
  8.   return true;
  9.  }
  10.  
  11.  function load_page($interface_id){
  12.   global $interfaces;
  13.   $i=mt_rand(1,12000);
  14.   while (file_exists('dmp-'.$i.'.html')){
  15.    $i=mt_rand(1,12000);
  16.   }
  17.  
  18.   system('wget "http://anidb.net/perl-bin/animedb.pl?show=anime&aid='.$i.'" -O dmp-'.$i.'.html.gz --tries=10 --timeout=60 '.
  19.          '--user-agent="'.$interfaces[$interface_id]->useragent.'" '.
  20.          '--bind-address '.$interfaces[$interface_id]->ip.' '.
  21.          '--referer="http://anidb.net/" '.
  22.          '--cookies=on --keep-session-cookies --save-cookies=anidb_cookies_'.$interface_id.'.txt');
  23.   @unlink('dmp-'.$i.'.html');
  24.   if (filesize('dmp-'.$i.'.html.gz')<1000){
  25.    echo "\nAttention! Site does not respond!";
  26.    $interfaces[$interface_id]->next=time()+300;
  27.    return;
  28.   }
  29.  
  30.   system('gunzip dmp-'.$i.'.html.gz');
  31.   $buf=file_get_contents('dmp-'.$i.'.html');
  32.   if (preg_match('|YOU HAVE BEEN AUTO-BANNED|', $buf)){
  33.    @unlink('dmp-'.$i.'.html');
  34.    echo "\nAttention! We was banned!";
  35.    $interfaces[$interface_id]->next=time()+12*3600;
  36.    return;
  37.   }
  38.  
  39.   if (mt_rand(0,10)==0){
  40.    $interfaces[$interface_id]->next=time()+mt_rand(30,40);
  41.   }else{
  42.    $interfaces[$interface_id]->next=time()+mt_rand(2,5);
  43.   }
  44.  }
  45.  
  46.  function load_page_test($interface_id){
  47.   global $interfaces;
  48.   echo "\n".$interface_id;
  49.   for ($i=0;$i<3;$i++){echo '.';sleep(1);}
  50.   $interfaces[$interface_id]->next=time()+mt_rand(2,5);
  51.  }
  52.  
  53.  $useragents=array(
  54.   'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36',
  55.   'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0',
  56.   'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko',
  57.  
  58.  
  59.   'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.41 Safari/537.36',
  60.   'Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53',
  61.   'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36',
  62.   'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0',
  63.   'Mozilla/5.0 (iPad; CPU OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/30.0.1599.16 Mobile/11B511 Safari/8536.25',
  64.   'Opera/9.80 (Windows NT 6.0; Edition Yx 01) Presto/2.12.388 Version/12.16',
  65.   'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36',
  66.   'Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/31.0.1650.18 Mobile/11B554a Safari/8536.25',
  67.   'Mozilla/4.0 (compatible; MSIE 6.0; Update a; AOL 6.0; Windows 98)',
  68.   'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36',
  69.   'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)',
  70.   'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2)',
  71.   'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) YaBrowser/1.1.1084.5409 Chrome/19.1.1084.5409 Safari/536.5',
  72.   'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.1284.68',
  73.   'Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0',
  74.   'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1761.0 Safari/537.36',
  75.   'Opera/9.80 (Windows NT 6.1; Edition Yx 01) Presto/2.12.388 Version/12.16',
  76.   'Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9Z999',
  77.   'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) YaBrowser/1.1.1084.5409 Chrome/19.1.1084.5409 Safari/536.5',
  78.   'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; MRA 6.0 (build 5993); MRA 8.0 (build 5784); InfoPath.2)',
  79.   'Opera/9.80 (Windows NT 5.1; Distribution 00) Presto/2.12.388 Version/12.16',
  80.   'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1230.0 Safari/537.1',
  81.   'Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
  82.   'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.12124 YaBrowser/13.12.1599.12124 Safari/537.36',
  83.   'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)',
  84.   'Mozilla/5.0 (Windows NT 6.1; rv:27.0) Gecko/20100101 Firefox/27.0',
  85.   'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 YaBrowser/13.10.1500.9323 Safari/537.36',
  86.   'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.0.3705)',
  87.  );
  88.  
  89.  $interfaces=array(
  90.   (object)array('ip'=>'', 'next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] ),
  91.   (object)array('ip'=>'',  'next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] ),
  92.   (object)array('ip'=>'',  'next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] ),
  93.   (object)array('ip'=>'', 'next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] ),
  94.  
  95.   (object)array('ip'=>'','next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] ),
  96.   (object)array('ip'=>'',    'next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] ),
  97.   (object)array('ip'=>'', 'next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] ),
  98.   (object)array('ip'=>'',   'next'=>0, 'useragent'=>$useragents[mt_rand(0, count($useragents)-1)] )
  99.  );
  100.  print_r($interfaces);
  101.  
  102.  for (;!is_load_complete();){
  103.   $interface_id=-1;
  104.  
  105.   for ($i=mt_rand(0,count($interfaces)-1);
  106.        $interface_id==-1;
  107.        $i=mt_rand(0,count($interfaces)-1)){
  108.    if ($interfaces[$i]->next<=time()){
  109.     $interface_id=$i;
  110.     break;
  111.    }
  112.   }
  113.   if ($interface_id==-1){
  114.    echo "\nThere is no interfaces at all";
  115.    sleep(1);
  116.    continue;
  117.   }
  118.  
  119.   load_page($interface_id);
  120.  
  121.  
  122.  }
  123. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement