zoukankan      html  css  js  c++  java
  • 目录扫描编写

    use HTTP::UserAgent;
    my $fp = open 'result.txt', :w;
    my @threads; #控制线程数目
    sub MAIN (Str $ip, Str $dict) {
            #
            #判断是否是文件
            if $dict.IO.f {
    
                #不要把文件一次进数组, 一行一行读就行
                for $dict.IO.lines -> $line {
                  push @threads, start {
                      #拼接url
                      my $ua = HTTP::UserAgent.new;
                      my $target = $ip~'/'~$line;
                      say 'Fetch: '~$target;
                      my $html = $ua.get($target);
                      #查看状态码
                      #say $html.status-line;
                      $fp.say($target => $html.status-line) if $html.status-line ~~ /200/;
                  };
                  #控制线程 数
                  if @threads == 4 {
                      await Promise.anyof(@threads);
                      @threads .= grep({!$_});
                  }
                }
            }else {
                say $dict~' Not exists or not a file!';
                #不是文件或不存在就提示
            }
        await @threads;
    }
  • 相关阅读:
    求树的某一层的节点最多
    快排 PAT 1101
    PAT 1098
    PAt 1099
    多项式求和
    pat 1100
    getline 函数
    数字的标准写法
    线性回归
    HTTP 中状态码 302的使用场景
  • 原文地址:https://www.cnblogs.com/perl6/p/7447702.html
Copyright © 2011-2022 走看看