Web服务器阻止libwww-perl请求

时间:2018-08-10 23:57:05

标签: python perl web-scraping block http-status-code-403

我第一次使用Web抓取脚本(Perl语言)时,它运行良好,但在3500(获取请求)后服务器返回403错误(禁止|未ip禁止),但是在(python语言)中使用相同的脚本时,我找到了同样的问题,但在3500个请求后我得到了403(24小时后重新运行),我不知道问题是什么以及如何解决

我了解了libwww-perl:

https://cloudkul.com/blog/block-libwww-perl-attack-in-apache-web-server/

1 个答案:

答案 0 :(得分:-1)

使用agent method provided by LWP::UserAgent更改“用户代理标识字符串”。

应该应根据客户端标识字符串解决阻塞问题。
不会解决基于滥用行为的阻止。

perldoc LWP::UserAgent

  

代理

  my $agent = $ua->agent;
  $ua->agent('Checkbot/0.4 ');    # append the default to the end
  $ua->agent('Mozilla/5.0');
  $ua->agent("");                 # don't identify
     

获取/设置用于标识网络上用户代理的产品令牌。代理值在请求中作为User-Agent标头发送。

     

默认值为libwww-perl/#.###形式的字符串,其中#.###替换为该库的版本号。

     

如果提供的字符串以空格结尾,则会在其后附加默认libwww-perl/#.###字符串。

     

用户代理字符串应为一个或多个简单产品标识符,其可选版本号由/字符分隔。

相关问题