简体   繁体   English

wget与Perl的lwp有什么不同?

[英]how does wget differ from Perl's lwp?

Im required to use wget for its ability to work like a crawler to develop one for my project. 我需要使用wget才能像爬虫一样为我的项目开发一个。 But all around in google searches im seeing people recommend to use LWP instead of Wget. 但是在谷歌搜索中我看到人们建议使用LWP而不是Wget。 Can you guys enlighten me on why this is so? 你们能告诉我为什么会这样吗?

If you're writing Perl and need to make an HTTP request, you should generally use LWP. 如果您正在编写Perl并且需要发出HTTP请求,则通常应该使用LWP。 It's silly to shell out to do something that is easily supported within the Perl process. 在Perl进程中做一些容易支持的事情是愚蠢的。

If you want to do something more complex, like recursive web crawling, you may want to look at the WWW::Mechanize or Mojolicious modules available from CPAN. 如果你想做一些更复杂的事情,比如递归网页抓取,你可能想看看CPAN提供的WWW::MechanizeMojolicious模块。 But at that point it might be reasonable to shell out to take advantage of an external tool that already has recursive web-crawling capability. 但在那时,可能有必要利用已经具有递归网络爬行功能的外部工具。

If you're writing a shell script rather than a Perl program, then you have no choice but to use an external tool. 如果您正在编写shell脚本而不是Perl程序,那么您别无选择,只能使用外部工具。 The choice among wget , curl , and the LWP scripts ( lwp-request , GET , etc) really comes down to what's easiest for your use case. wgetcurl和LWP脚本( lwp-requestGET等)之间的选择实际上归结为最简单的用例。 They all have have approximately the same features, but some things are easier in one tool than the others. 它们都具有大致相同的功能,但有些东西在一个工具中比其他工具更容易。 Use what's readily available for your system; 使用您的系统随时可用的内容; there's usually more than one option, in which case you should give them all a try - read the doc, try a few use cases, see which one you like. 通常有多个选项,在这种情况下你应该尝试一下 - 阅读文档,尝试一些用例,看看你喜欢哪一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM