"获得"不在perl中工作 [英] "get" not working in perl

查看:90
本文介绍了"获得"不在perl中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是perl的新手。在过去的几天里,我制作了一些简单的脚本,通过get将网站的源代码保存到我的电脑中。他们做他们应该做的,但不会得到作为论坛的网站的内容。非论坛网站工作得很好。
任何想法发生了什么?这是问题块:

  my $ url ='http://www.computerforum.com/'; 
my $ content = get $ url ||死无法获取内容;


解决方案

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


get()函数将获取由给定URL标识的文档并将其返回。如果失败,它将返回undef。 [b]

当您使用此功能访问网络时,您将无法检查响应代码或响应标题(如Content-Type)。如果您需要这些信息,您应该使用完整的面向对象接口(请参阅LWP :: UserAgent)。

您真的需要更好的错误报告,切换到 LWP :: UserAgent 库。我怀疑论坛软件阻止了LWP用户代理。


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 $content = 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.

这篇关于"获得"不在perl中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆