简体   繁体   English

如何使用Perl下载网页?

[英]How can I download a web page using perl?

I'm new to perl. 我是perl的新手。 Now I need to write a perl program to download web pages from a web site periodically. 现在,我需要编写一个perl程序来定期从网站下载网页。 I see some useful methods to establish network connections and get content, but I don't know which is better. 我看到了一些有用的方法来建立网络连接并获取内容,但是我不知道哪个更好。 Can anybody recommend some libraries to download web pages with sample codes, or tutorial sites? 有人可以推荐一些库来下载带有示例代码的网站或教程网站吗? I hope it's simple to start with, like the pseudo codes: 我希望开始时很简单,例如伪代码:

use library; 使用图书馆

open a connection; 打开连接; get the content; 获取内容; process if success or handle error. 如果成功或处理错误则进行处理。

And it's better to have cookie support. 而且最好有cookie支持。

Thanks. 谢谢。

Check the LWP module . 检查LWP模块 The documentation includes examples. 该文档包括示例。

I recommend libcurl. 我推荐libcurl。 It's simple and has full functionality to handle almost everything about http including cookie support. 它很简单,并且具有完整的功能,可以处理有关http的几乎所有内容,包括cookie支持。 And it has many different language bindings, so it's easy for you to turn to other languages. 而且它具有许多不同的语言绑定,因此您可以轻松转向其他语言。 Using cpan to search for perl's binding. 使用cpan搜索perl的绑定。 The official website is http://curl.haxx.se 官方网站是http://curl.haxx.se

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

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