文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Perl模拟浏览器(cookie)抓Email

Perl模拟浏览器(cookie)抓Email

时间:2009-03-18  来源:snowtty

Perl模拟浏览器(cookie)抓Email

关键字: email perl Perl代码
  1. #!/usr/bin/perl -w   
  2.   
  3.   
  4. #use CGI qw(:standard);   
  5. use LWP::UserAgent;   
  6. use HTTP::Request::Common;   
  7. use HTTP::Request::Common qw(POST);   
  8. #$e=exp(1);   
  9. open(OPENFILE,"keyword.txt") or die("open file failure!");   
  10. #$/=undef;   
  11. #$cgi=new CGI;   
  12. #print $cgi->header;   
  13. $email="email.txt";   
  14. $k=1;   
  15. while($line=<OPENFILE>){   
  16.        
  17.     #if($line=~s/##[0-9a-zA-Z]+##/$e/){   
  18.     #    print $line;   
  19.     #   }   
  20.        #else   
  21.        #{   
  22.        #    print $line;   
  23.         #}   
  24.         #print $line;   
  25.         if($line){   
  26.             
  27.              
  28.         $line=~s/\n|\r/ /ig;   
  29.         $line=~s/\s+$//ig;   
  30.         if( -e $email )   
  31.         {   
  32.             open(SRC,">>$email");   
  33.         }   
  34.         else{   
  35.             open(SRC,">$email");   
  36.         }   
  37.         $email1=getEmail($line);   
  38.         if($email1){   
  39.             print SRC "$line\t$email1\r\n";    
  40.             }   
  41.         else{   
  42.             printf SRC "$line\r\n";    
  43.             }   
  44.         close(SRC);    
  45.         sleep(10);   
  46.         if($k%8==1){   
  47.         `wget http://www.lead411.com`;   
  48.         }   
  49.         print "$k\n";   
  50.         $k++;   
  51.         }   
  52.        
  53. }   
  54. print "Total Record:\$";   
  55. close(OPENFILE);   
  56. #$slurp=<OPENFILE>;   
  57. sub getEmail{   
  58. my $agent=LWP::UserAgent->new;   
  59. my @header=(   
  60. 'User-Agent'=>'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; iCafeMedia; .NET CLR 2.0.50727; CIBA)',   
  61. 'Accept' => '*/*',   
  62. 'Accept-Charset' => 'gzip, deflate',   
  63. 'Accept-Language' => 'zh-cn',   
  64. 'Cookie'=> 'Tango_UserReference=38D8FF1624305B16496E9808; MTCCK=1; _csuid=48feeef505683659; cookmcnt=999; CID=1459382; cookMemberName=YunFan; cookMemberID=61448; [email protected]; DLDExec=OK; __utma=232384002.1655516880.1231991960.1231994793.1232000250.3; __utmb=232384002; __utmc=232384002; __utmz=232384002.1231991960.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)'  
  65. );   
  66. my $url="http://www.lead411.com/allsearch.taf?_function=headersearch&SearchParam=$_[0]&SearchType=Company";   
  67. #print $_[0]."\n";   
  68. #my $arg={'SearchParam'=>"$_[0]",'SearchType'=>'Company'};   
  69. #print $arg->{SearchParam}."\n";   
  70. my $temp2="";   
  71. my $temp="",$temp1="";   
  72. #my $req=HTTP::Request->new(GET=>"$url",@header);   
  73. my $res =$agent->get($url,@header);   
  74. my $content="";   
  75. #my $res =$agent->post($url,$arg,'Content_Type' => 'form-data');   
  76. #request($req);get($url,@header);   
  77. if($res->is_success){   
  78.     $content= $res->content;   
  79.     #print "test";   
  80.     #$content=~s/\s+|>|<|\///ig;   
  81.     #print $content;   
  82.        while($content=~/company.taf\?_function=detail&Company_uid1=(\d+)&_UserReference=(\w+)/ig)   
  83.        {   
  84.             $temp=$1;$temp1=$2;   
  85.             if($temp and $temp1){   
  86.                 $url='http://www.lead411.com/company.taf?_function=detail&Company_uid1='.$temp.'&_UserReference='.$temp1;   
  87.                 $content=~s/http:\/\/www\.lead411\.com\/company\.taf\?_function=detail\&Company_uid1=$temp\&_UserReference=$temp1//ig;   
  88.                 print $url."\n";   
  89.                 $res =$agent->get($url,@header);   
  90.                 if( $res->is_success)   
  91.                 {   
  92.                 $content=$res->content;   
  93.                 $content=~s/\s+|>|<|\///ig;   
  94.                 $content=~s/\s+//ig;   
  95.                 $i=0;$temp="";   
  96.                 do{   
  97.                    $i=index($content,'CEO',$i);   
  98.                    $temp=substr($content,$i,150);   
  99.                    #print $temp;   
  100.                    if($temp=~/"mailto:(.*)"font/ig){   
  101.                         $temp2.=$1;   
  102.                         print $_[0]."---------------".$temp2."\n";   
  103.                    }   
  104.                      
  105.                    if($i!=-1){   
  106.                         $i=$i+150;   
  107.                    }   
  108.                    else{   
  109.                         $i=0;   
  110.                     }   
  111.                 }while($i)   
  112.                 #print $content;   
  113.                    
  114.                 #if($content=~/(<TD>.*?CEO.*?<\/TD> <TD>.*?mailto:"[A-Z0-9._%-]+\@[A-Z0-9._%-]+\.[A-Z]{2,4}"<\/TD>)/ig)   
  115.                 #{   
  116.                 #   print "test $1";   
  117.                 #}   
  118.                 #print $content;   
  119.                 #$temp=~/mailto:"[A-Z0-9._%-]+\@[A-Z0-9._%-]+\.[A-Z]{2,4}"/ig;                   
  120.                    
  121.             }   
  122.            
  123.             }   
  124.         }   
  125.     }   
  126.     return $temp2;   
  127. }   
  128.        
  129. exit;  
相关阅读 更多 +
排行榜 更多 +
搞怪达人

搞怪达人

休闲益智 下载
奶酪

奶酪

游戏工具 下载
匿名爱人游戏

匿名爱人游戏

冒险解谜 下载