gpt4 book ai didi

perl - Active perl 机械化错误请求错误

转载 作者:行者123 更新时间:2023-12-01 01:05:56 30 4
gpt4 key购买 nike

我正在尝试使用 Mechanize 获取 https,但失败了:

use strict;
use warnings;

use IO::Socket::SSL;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new;
$mech->proxy(['https','http'], 'http://proxy:8080/');
$mech->get('https://www.google.com');

print $mech->content;

错误:
Error GETing https://www.google.com: Bad Request at perl4.pl line 9.

当我尝试使用 LWP::UserAgent我可以毫无错误地获取 https:
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->proxy(['https','http'], 'http://proxy:8080/');
$ua->get('https://www.google.com');

任何人都可以帮忙解决这个问题吗?

目前使用机械化 1.72

最佳答案

WWWW::Mechanize 基于 LWP::UserAgent,多年来它对 https 代理请求有一个奇怪的想法,例如它不是使用 CONNECT 请求来构建隧道然后升级到 SSL,而是发送带有 https-URL 的 GET 请求。
https://rt.cpan.org/Ticket/Display.html?id=1894

一个修复终于合并到了libwwww-perl github仓库,但是不知道什么时候会发布新版本的LWP。与此同时,您可能会使用 Net::SSLGlue::LWP,它会修补 LWP 以提供对 https 代理的适当支持(我是 Net::SSLGlue::LWP 和 LWP 修复程序的作者)。

关于perl - Active perl 机械化错误请求错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18712307/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com