6

https サイトの場合は perl を使用して TOR 経由で Web サイトにアクセスできませんが、http サイトの場合はそうではありません。

#!/usr/bin/perl
use strict;

use WWW::Mechanize;
use LWP::Protocol::socks;
use LWP::Protocol::https;
use utf8;

my $mech = WWW::Mechanize->new(timeout => 60*5);
$mech->proxy(['http', 'https'], 'socks://localhost:9150');
$mech->get("https://www.google.com");

次のエラー メッセージが表示されます: Error GETing https://www.google.com : Status read failed: Bad file descriptor at line 10" ここで、行 i10 はプログラムの最後の行です。

TOR ブラウザでは、「https://www.google.com」をポート 9150 で正常に表示できます。ActivePerl 5.16.2 を使用しています。Vadalia 0.2.21 および Tor 0.2.3.25。私は Windows マシンを使用しており、メインのインターネット ブラウザは Mozilla です。

次のコマンドでパッケージをインストールしようとしました:

cpan LWP::UserAgent
ppm install LWP::Protocol::https
cpan LWP::Protocol::https
ppm install LWP::Protocol::socks
cpan LWP::Protocol::socks
ppm install Mozilla::CA
ppm install IO::Socket::SSL
ppm install Crypt::SSLeay
cpan Crypt::SSLeay

助けてくれてありがとう!他に提供できる情報があるかどうかお知らせください。

4

3 に答える 3

2

少し前に、WWW::Curl::Easy を使用して Tor で https サイトを通過する方法を見つけました。LWP を使用して同じ問題を見つけたからです。その後、すべての html をファイルに保存し、WWW::Mechanzie または HTML::TreeBuilder を使用してそれらを解析します。

post forms などのサイトとの対話性を高めたい場合は、curl と対話する必要があるため、このソリューションはより退屈になる可能性があります。

package Curl; use warnings; use WWW::Curl::Easy; use WWW::UserAgent::Random; my $curl = WWW::Curl::Easy->new; my $useragent = rand_ua("browsers"); my $host = 'localhost'; my $port = '9070'; my $timeout = '20'; my $connectTimeOut= '20'; &init; sub get { my $url = shift; $curl->setopt(CURLOPT_URL, $url); my $response_body; $curl->setopt(CURLOPT_WRITEDATA,\$response_body); my $retcode = $curl->perform; if ($retcode == 0) { print("Transfer went ok Http::Code = ".$curl->strerror($retcode)."\n"); my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE); # judge result and next action based on $response_code return \$response_body; } else { # Error code, type of error, error message print("An error happened: $retcode ".$curl->strerror($retcode)." ".$curl->errbuf."\n"); return 0; } } sub init { #setejem el proxy $curl->setopt(CURLOPT_PROXY,"$host:".$port); $curl->setopt(CURLOPT_PROXYTYPE,CURLPROXY_SOCKS4); #posem les altres dades $curl->setopt(CURLOPT_USERAGENT, $useragent); $curl->setopt(CURLOPT_CONNECTTIMEOUT, $connectTimeOut); $curl->setopt(CURLOPT_TIMEOUT, $timeout); $curl->setopt(CURLOPT_SSL_VERIFYPEER,0); $curl->setopt(CURLOPT_HEADER,0); }

これがあなたを助けることを願っています!

于 2013-09-24T13:22:59.567 に答える
1

使用しているプロキシがすでに HTTPS プロキシ (つまり、CONNECT プロキシ) である可能性があります。その場合、これは機能するはずです(テストされていません):

#!/usr/bin/perl
use strict;

use WWW::Mechanize;
use LWP::Protocol::socks;
use LWP::Protocol::https;
use utf8;

my $mech = WWW::Mechanize->new(timeout => 60*5);
$mech->proxy(['http'], 'socks://localhost:9150');
$mech->proxy(['https'], 'https://localhost:9150'); ### <-- make https go over https-connect proxy

$mech->get("https://www.google.com");
于 2013-03-28T12:17:03.157 に答える