如何为 LWP::RobotUA 指定自己的 robots.txt 规则
我编写了一个脚本来使用 LWP::RobotUA 检查我自己的网站。我想避免频繁请求我的 robots.txt。
LWP::RobotUA 的规则参数应该允许我指定这些,但我不太明白“允许所有页面”应该传递什么。
my $ua = LWP::RobotUA->new(agent=>'my-robot/0.1', from=>'[email protected]', rules=> ??? );
I wrote a script to check my own websites with LWP::RobotUA. I would like to avoid the frequent requests for my robots.txt.
The rules parameter for LWP::RobotUA should allow me to specify those, but I don't qiute understand what should be passed for "allow all pages".
my $ua = LWP::RobotUA->new(agent=>'my-robot/0.1', from=>'[email protected]', rules=> ??? );
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
LWP::RobotUA 是添加了
robots.txt
支持的 LWP::UserAgent。如果您不想请求robots.txt
,那么只需使用LWP::UserAgent。或者,子类化 LWP::RobotUA 并重写 simple_request 方法并删除 robots.txt 和规则处理。
LWP::RobotUA is LWP::UserAgent with
robots.txt
support added. If you do not want to requestrobots.txt
, then just use LWP::UserAgent.Alternatively, subclass LWP::RobotUA and override the
simple_request
method and strip outrobots.txt
and rule handling.经过更多研究,我认为提供机器人规则的预期方法是对 WWW::RobotRules 进行子类化。
After more research, I think the intended way to supply robots rules is by subclassing WWW::RobotRules.