163爬

<?php
header("Content-Type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
//时区
ignore_user_abort(); //关掉浏览器,PHP脚本也可以继续执行.
set_time_limit(0); // 通过set_time_limit(0)可以让程序无限制的执行下去


//得到数组(无限种组合)
$keywordData = readKeyword();
//遍历(没有注册的保存)
foreach ($keywordData as $value) {
   test163($value);
}

function keyword(){
    $zimuData = ['a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    $Data = ['a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9'];


    $passwrod = [];
    $x = 0;
    while($x<500000){
        


        //第一位
        $one = $zimuData[rand(0,count($zimuData)-1)];
        //第二位
        $two = $Data[rand(0,count($Data)-1)];   

        //第一种情况 axxxxxx
        /*$passwrod[] = $one.$two.$two.$two.$two.$two;*/
        //第二中 aaaaax
        /*$passwrod[] = $one.$one.$one.$one.$one.$two;*/
        //第三种 axaxax
       /* $passwrod[] = $one.$two.$one.$two.$one.$two;*/
       //第四种  aaaxxx
        /*$passwrod[] = $one.$one.$one.$two.$two.$two;*/
        //第五种  aabbcc
        $three = $Data[rand(0,count($Data)-1)];   
        $passwrod[] = $one.$one.$two.$two.$three.$three;

        $x++;
    }
    //去重
    $passwrod = array_unique($passwrod);    
    return $passwrod;
}


//测试是否注册并写入
function test163($name){
    $url = 'https://zc.reg.163.com/checkName?id=0D01F7D851B271968D5B35E89202905BC6092133D3C37625473CF2F8EAF28FC7171B29A2CB5D39109AA79FD2213EB3BC0C2FB85B7B60CA6CB0491C37D20B20E4BBD7A26894CE8F0114FA96CC3AD21D06&channel=6&userName='.$name.'%40163.com&nocache=1535619264598&rtid=8xon005EAKVgrMOtSh0btbJNoiXdhOhr';

    //获取json数组
    $data = json_decode(_grab($url),true);
    $result = '';
    if($data['ret']==104){
       $result = '-------------------------'.$name.'-------------------------';
     
    }
    else if($data['ret']==407){
       $result =  $name.':不能注册!';
    }
         //写入日志
        my_log($result);   
}

//写入日志date('m_d')
function my_log($data){
   $log_file = date('m_txt__d__',time()).'.txt';
  /* $content =var_export($data,TRUE);*/
   $data .= "\r\n";
   file_put_contents($log_file,$data, FILE_APPEND);
}


function _grab($curl,$postInfo='',$cookie='',$referer='',$userAgent=''){
     $ch = curl_init();  
     curl_setopt($ch, CURLOPT_URL, $curl);  
     //不输出头
     curl_setopt($ch, CURLOPT_HEADER, 0);   
     //以字符串返回获取的信息,不直接输出
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     //如果是https链接,不验证证书
     if(preg_match('/https/i', $curl)){
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     }
     //POST
     if($postInfo){
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$postInfo);
     }
     //加入cookie
     if($cookie){
         curl_setopt($ch,CURLOPT_COOKIE,$cookie);
     }
     //模拟来路
     if($referer){
         curl_setopt($ch, CURLOPT_REFERER, $referer);
     }
     //模拟环境
     if($userAgent){
         curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
     }
     //执行
     $content = curl_exec($ch);  
     //错误处理
     if ($content  === false) {  
       return "网络请求出错: " . curl_error($ch);  
       exit();  
     }  
     return $content;
}    



//从txt一行一行成数组
function readKeyword(){

    $data = [];
    $f= fopen("danci.txt","r");
    $count = 0;
    while (!feof($f))
    {
      $line = fgets($f);
      $line = substr($line, 0,6);
      $data[] = $line;
    }
    fclose($f);
    return $data;
}

 

posted @ 2018-08-30 20:29  cl94  阅读(523)  评论(0)    收藏  举报