Hi Monks , I am trying to connect to url https://www.irctc.co.in . I searched in earlier posts and tried 4-5 ways but still same problem persists . I am giving here 2 methods that I tried along with code and error . Please help . I am using strawberry perl and WinXP

Method 1 :

#!/usr/bin/perl use strict; use WWW::Mechanize; use Crypt::SSLeay; my $mech = WWW::Mechanize->new(autocheck => 1,noproxy => 1); $mech->cookie_jar(HTTP::Cookies->new); $ENV{HTTPS_PROXY} = 'my_proxy:port/'; $mech->agent('Mozilla/5.0'); $mech->proxy(['https', 'http', 'ftp'], 'my_proxy:port'); # http $mech->get("http://www.google.com"); my $test = $mech->forms(); # https $mech->get("https://www.irctc.co.in") ; die $mech->response->status_line unless $mech->success; my $test = $mech->forms();
<error> main::(pnr_2.perl:9): my $mech = WWW::Mechanize->new(autocheck => 1,noproxy => 1); DB<1> r Error GETing https://www.irctc.co.in: Bad Request at pnr_2.perl line 23 at C:/strawberry/perl/lib/WWW/Mechanize.pm line 2747 WWW::Mechanize::_die('Error ', 'GET', 'ing ', 'URI::https=SCALAR(0x19a0a04)', ': ', 'Bad Request') called at C:/strawberry /perl/lib/WWW/Mechanize.pm line 2734 WWW::Mechanize::die('WWW::Mechanize=HASH(0x15ddde4)', 'Error ', 'GET', 'ing ', 'URI::https=SCALAR(0x19a0a04)', ': ', 'Bad Request') called at C:/strawberry/perl/lib/WWW/Mechanize.pm line 2383 WWW::Mechanize::_update_page('WWW::Mechanize=HASH(0x15ddde4)', 'HTTP::Request=HASH(0x19d9e14)', 'HTTP::Response=HASH(0x19a 0f34)') called at C:/strawberry/perl/lib/WWW/Mechanize.pm line 2213 WWW::Mechanize::request('WWW::Mechanize=HASH(0x15ddde4)', 'HTTP::Request=HASH(0x19d9e14)') called at C:/strawberry/perl/ve ndor/lib/LWP/UserAgent.pm line 389 LWP::UserAgent::get('WWW::Mechanize=HASH(0x15ddde4)', 'https://www.irctc.co.in') called at C:/strawberry/perl/lib/WWW/Mech anize.pm line 407 WWW::Mechanize::get('WWW::Mechanize=HASH(0x15ddde4)', 'https://www.irctc.co.in') called at pnr_2.perl line 23 Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<1> </error>

Method 2:

#!perl use warnings; use diagnostics; #use LWP::UserAgent; use LWP::Simple; use Crypt::SSLeay; print "Content-type: text/html\n\n"; #<-- for viewing in browser # Create a user agent object my $ua = LWP::UserAgent->new; $ua->proxy(['http', 'ftp'], 'my_proxy:port'); #my $response = $ua->get('http://www.tradeindia.com/Seller/Agricultu +re/Cashews/'); my $response = $ua->get('https://www.irctc.co.in'); ##':content_file' => $out,); if ($response->is_success) { print "\n i am in finally"; } else { die $response->status_line; }
<error> main::(pnr_3.perl:7): print "Content-type: text/html\n\n"; #<-- for viewing in browser DB<1> r Content-type: text/html 500 Connect failed: connect: No connection could be made because the target machine actively refused it.; No connection could be made because the target machine actively refused it. at pnr_3.perl line 21. at pnr_3.perl line 21 Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<1> </error>

Thanks

Vishy


In reply to HTTPS connection problems WWW::Mechanize , LWP by vishy_acts

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.