开发者

"get" not working in perl

I'm new to perl. In the past few days, I've made some simple scripts that save websites' source codes to my computer via "get." They do what they're supposed to, but will not get the content of a website which is a forum. Non-forum websites work just fine. Any idea what's going on? Here's the problem chunk:

my $url = 'http://www.computerforum.com/';
my $conten开发者_如何学JAVAt = get $url || die "Unable to get content";


http://p3rl.org/LWP::Simple#get:

The get() function will fetch the document identified by the given URL and return it. It returns undef if it fails. […]

You will not be able to examine the response code or response headers (like 'Content-Type') when you are accessing the web using this function. If you need that information you should use the full OO interface (see LWP::UserAgent).

You really need better error reporting, switch to the LWP::UserAgent library. I suspect the forum software blocks the LWP user agent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜