Author Topic: run perl script via proxy in linux  (Read 123 times)

somying som

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
run perl script via proxy in linux
« on: สิงหาคม 11, 2021, 03:45:05 PM »
#!usr/bin/perl
use LWP::UserAgent;

# override HTTPS setting in LWP to work with a proxy
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$ENV{HTTPS_PROXY}               = 'http-proxy.yourcompany.com:80';
$ENV{HTTPS_PROXY_USERNAME}      = 'username';
$ENV{HTTPS_PROXY_PASSWORD}      = 'password';

$ua = new LWP::UserAgent;

# make a https request
my $req = HTTP::Request->new(GET => 'https://mail.google.com/');
my $res = $ua->request($req);
print $res->as_string;

กำถั่ว