I am kinda new to Perl but i am trying, what basically i want to do is login to IITS system and go to particular page parse it and get webpage content.Though i havent reached to the point for parsing i want to go step by step. But I get Response status is: 405 Method not allowed error. Help Needed
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common ; #!/usr/bin/perl use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common ; use HTTP::Request; use HTTP::Response; use HTTP::Headers; use HTML::Parser; use XML::Parser; my $login = { username => 'guestuser', # login form + to post to IITS userPassword => 'temp', ip_address => '10.70.30.20', successURL => 'home.asp', submit => 'login', }; my $ua = LWP::UserAgent->new( keep_alive => 1 ); # timeout => 30 ); my $cookie_jar = HTTP::Cookies->new; # Create a coo +kie store object $cookie_jar->add_cookie_header($request); $ua->cookie_jar( $cookie_jar ); # Associate co +okie store with the user agent my $header = HTTP::Headers->new( Content_Type => 'text/html' +, # Create an HTTP headers object User_Agent => 'Release_Bu +ild/1.0' ); $header->as_string; my $request = HTTP::Request::Common::POST( 'http://10.1.19.22', $l +ogin, User_Agent => 'Relea +se_Build/1.0' ); $request->as_string; my $response = $ua->request( $request ); # Send IITS lo +gin print $response->as_string(); $cookie_jar->extract_cookies($response); # Save session + cookie returned in the response $cookie_jar->as_string(); while ($response->is_redirect) { my $location = $response->header( "location" ); $request = HTTP::Request->new( "GET", "http://10.1.19.22/" . $ +location, $header ); print $request->as_string; $response = $ua->request( $request ); print $response->as_string(); } unless ($response->is_success) { print "Response status is: ", $response->status_line(); return undef; }

In reply to webpage login by Vanquish

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.