Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 为什么LWP在OS X上失败,但在我的Windows 10上却没有?_Perl_Get_Lwp - Fatal编程技术网

Perl 为什么LWP在OS X上失败,但在我的Windows 10上却没有?

Perl 为什么LWP在OS X上失败,但在我的Windows 10上却没有?,perl,get,lwp,Perl,Get,Lwp,我用perl 5.14.2在(1)PC/Windows 10上尝试了getstore()和get(),用perl 5.18.2在(2)Mac/OS X 10.11.6上尝试了getstore()和get() getstore生成的一些状态代码如下:200是一个好的URL,500是“服务器未能交付”。 有没有办法解决这个问题 use strict; use warnings; use LWP::Simple; print "\nThe below is successful on bo

我用perl 5.14.2在(1)PC/Windows 10上尝试了getstore()和get(),用perl 5.18.2在(2)Mac/OS X 10.11.6上尝试了getstore()和get()

getstore生成的一些状态代码如下:200是一个好的URL,500是“服务器未能交付”。 有没有办法解决这个问题

use strict;
use warnings;
use LWP::Simple;

print "\nThe below is successful on both Windows 10 and OS X\n";
my $url = "http://example.com"; 
my $status = getstore($url,"/tmp/web.html"); 
print "Result of getstore for \"$url\"\n is \"$status\" .  Success=" . is_success($status) . "\n";

print "\nThe below is successful on Windows 10 but not on OS X\n";
$url = "https://drive.google.com/open?id=1FqtZptibqeu4uKbv0vzinjWv5bwi8-Y2";
$status = getstore($url,"/tmp/web.html"); 
print "Result of getstore for \"$url\"\n is \"$status\" .  Success=" . is_success($status) . "\n";

print "\nPress Enter to exit";
my $ans =<stdin>;
使用严格;
使用警告;
使用LWP::Simple;
打印“\n以下内容在Windows 10和OS X上都成功\n”;
我的$url=”http://example.com"; 
my$status=getstore($url,“/tmp/web.html”);
打印“getstore for\”$url\“\n的结果为\“$status\”。Success=“。是成功($status)。“\n”;
打印“\n以下内容在Windows 10上成功,但在OS X上未成功\n”;
$url=”https://drive.google.com/open?id=1FqtZptibqeu4uKbv0vzinjWv5bwi8-Y2”;
$status=getstore($url,“/tmp/web.html”);
打印“getstore for\”$url\“\n的结果为\“$status\”。Success=“。是成功($status)。“\n”;
打印“\n按Enter键退出”;
我的$ans=;

根据以下文件:

libwww-perl核心不再捆绑用于SSL的协议插件。你 需要单独安装LWP::Protocol::https才能启用支持 用于处理https URL

因此,要访问https架构的URL,您需要首先安装,正如@DaveCross在评论中指出的那样。使用perlbrew perl版本5.32.0在macOs BigSur上测试:

$ cpanm LWP::Simple
$ cpanm LWP::Protocol::https
$ perl test.pl  # run your test script
The below is successful on both Windows 10 and OS X
Result of getstore for "http://example.com"
 is "200" .  Success=1

The below is successful on Windows 10 but not on OS X
Result of getstore for "https://drive.google.com/open?id=1FqtZptibqeu4uKbv0vzinjWv5bwi8-Y2"
 is "200" .  Success=1

Press Enter to exit
注:
它可能在Windows上工作的原因是
LWP::Protocol::https
出现在Windows上

请显示您尝试的代码,有关更多信息,请参阅是否尝试访问https URL?你安装了吗?@virgban:请不要在评论中共享代码,因为在评论中代码几乎不可读。戴夫·克罗斯:谢谢你提供关于HTTPS URL的提示。是的,这就是我想要检查的URL类型。Mac仅在使用LWP::Simple函数(get、getstore或head)时失败。当URL为HTTPS时,我尝试在Mac上安装LWP::Protocol::HTTPS,但失败了(此时我无能为力)。我已经从Metapan获得了一些perl模块,这些模块运行了好几次,总是使用原始代码,但这个https模块很难实现。我不知道如何继续,如果这个问题没有重新打开,我可能会放弃这项工作。我猜这两个“$cpanm”语句是要在OS X上的终端窗口中输入以进行安装的命令。如果是这样的话,我似乎还没有安装cpanm,现在还不确定是否要安装它。我以前使用过Metaspan中的原始Perl模块,而不是使用它们的“安装”,因为我不想让用户通过安装过程来使用我的产品。我有来自cpan的原始代码LWP::Protocol::https包/模块,但我没有使用它的专业知识(没有自述)。你能看到我使用原始代码的“方法论”的前进方向吗?