How to use WWW:Mechanize to login

前端 未结 2 1866
情话喂你
情话喂你 2021-01-26 05:44

I want to login to a persian blogging service . This is my code:

#!/usr/bin/perl

use WWW::Mechanize;

$mech = WWW::Mechanize->new();
$url =  \"http://blogfa.         


        
相关标签:
2条回答
  • 2021-01-26 06:05

    This should work:

    my $mech = WWW::Mechanize->new();
    $mech->get("http://blogfa.com/Desktop/Login.aspx?t=1");
    
    $mech->submit_form(
    
        with_fields => {
            'master$ContentPlaceHolder1$Uid'       => 'my username',
            'master$ContentPlaceHolder1$Password'  => 'my password',
        },
        button => 'master$ContentPlaceHolder1$btnSubmit',
    );
    
    0 讨论(0)
  • 2021-01-26 06:16

    The problem is, that WWW:Mechanize does not execute javascript. Since the site you want to log in uses javascript for logging in, its not able to do that.

    You could fix that problem by using WWW::Mechanize::Firefox, which allows you to execute javascript.

    0 讨论(0)
提交回复
热议问题