Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:18:08+00:00 2026-06-10T06:18:08+00:00

I am trying to login to Way2sms through LWP. The source code of the

  • 0

I am trying to login to Way2sms through LWP. The source code of the page says that the login form (which, in this case, appears to be the root node of everything within the body) has an action attribute of '', which I read in some other Stackoverflow post, points to the URL of the page containing that form. The name attribute for the mobile and password fields are available from the source code, so I tried this:

use URI;
use HTML::TreeBuilder;
use LWP;
open f, "> way2sms.txt";
$browser = LWP::UserAgent->new(agent=>'Mozilla/4.76 [en] (Windows NT 5.0; U)');
$resp = $browser->post("http://site2.way2sms.com/content/index.html",[username=>$username,password=>$password]);
if ( $resp->is_redirect ) {
    $resp = $browser->get( $resp->header('Location') );
}

print f $resp->content;
close f;

With the correct phone-number and passwords, the submission should return a personalized page, which among other things, contains a message like Welcome, Kaustav Mukherjee. So naturally, I expect the code to print out 5. However, although Logged is printed out denoting success, the 5 isn’t printed out, showing that the login failed. How to do it? (Please don’t suggest using Mechanize!)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:18:10+00:00Added an answer on June 10, 2026 at 6:18 am

    The response that you get is a 302 Moved Temporarily and not a 200 OK. Therefore, you need to fetch the content of the new page and not the content of the redirect response.

    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    
    use LWP::UserAgent;
    
    my $ua = LWP::UserAgent->new(
        agent =>
          'Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1',
        cookie_jar => {},
    );
    my $response = $ua->post(
        'http://site2.way2sms.com/Login1.action',
        {
            username => '1234567890',
            password => 'topsecret',
        }
    );
    if ( $response->is_redirect ) {
        $response = $ua->get( $response->header('Location') );
        print $response->decoded_content;
    }
    

    Some comments on your code:

    • Always use strict; and use warnings;
    • use autodie; or manually check if open succeeded or not
    • Prefer three argument open
    • Prefer lexical filehandles (open my $fh, …)
    • If you use barewords for filehandles make sure that they are capitalised (use warnings; will warn you)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send sms through Way2sms using Perl LWP. The login part
I am trying to Login or SugarCrm using REST. I have this code,, //Login
First, check this message which I was trying to do: Login To log on
I am trying to login to this page using Python. I tried using the
I have a page that is trying to login a user. at the top
I am trying to login into this page but I cannot for the life
The problem is that I am simply trying to login with this script and
I am trying to login to a form which has a hidden hash field.
I am trying to login using the library Mechanize. This the output i get
I am trying to login to a site using a login form and submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.