使用perl的LWP::UserAgent模块取得页面内容,并保存至文件中的代码。
例子:
#!/bin/perl -w
#
use LWP::UserAgent;
$user_agent = new LWP::UserAgent;
$request = new HTTP::Request('GET', 'http://www.jb200.com/doc/FAQs/index.html');
$response = $user_agent->request($request);
open FILEHANDLE, ">file.txt";
print FILEHANDLE $response->{_content};
close FILEHANDLE;