codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Problems in login using WWW::Mechanize  shekarkcb at 13:28 on Monday, June 09, 2008
 

Hi all,

I have tried to automate bittorrent site (browsing). So there it requires username and password. and then click button sign in. but i didn't find any ways login (enter next field) so. below are the ways i have tried ,please assist me if any mistakes.....

1st Method:-
use WWW::Mechanize;
my $m = WWW::Mechanize->new( autocheck => 1 );
$m->get("https://www.bittorrent.com/account/signin");
$mech->submit_form(
form_name => 3, #I don't know what is this simply i gave
fields => {
username => "abcd",
password => "abcd",
},
button => 'Sign In',
);

2nd Method:-

use WWW::Mechanize;
use HTTP::Cookies;
my $outfile = "Result.htm";
my $url = "https://www.bittorrent.com/account/signin";
my $username = "abcd";
my $password = "abcd";
my $cookiefile = 'cookies.txt';
my $cookie_jar = HTTP::Cookies->new(File => $cookiefile, autosave =>1);
my $mech = WWW::Mechanize->new();
$mech->cookie_jar($cookie_jar);
$mech->get($url);
print "form submit failed!", $mech->response->status_line, "\n" unless $mech->success;
$mech->set_visible( $username );
$mech->click_button(value => "Sign In");


3rd Method:-

use WWW::Mechanize;
use URI::URL;
use LWP::Simple;

$url="https://www.bittorrent.com/account/signin";
$m=WWW::Mechanize->new();
$m->get($url);
$content=$m->content;

open(FD,">>html");
print FD "$content\n";

$username="shekar";
$password="shekar";
$m->set_visible($username,$password);
$m->submit();



Please Sugest me to overcome this problem....
You can mail me @ shekarkcb@gmail.com

regards
shekar


  Re: Problems in login using WWW::Mechanize  lock.cda at 13:43 on Wednesday, July 23, 2008
 

Maybe you need the JavaScript plugin for mechanize (by default mechanize cannot execute JavaScript). In order to do it I can remember that exist a mechanize can work with firefox.

You has that plugin too: http://search.cpan.org/author/SPROUT/WWW-Mechanize-Plugin-JavaScript-0.002/lib/WWW/Mechanize/Plugin/JavaScript.pm

Another way is that you fill the variables which JavaScript fill (I don't know if fill is the correct word... I'm spanish and I saw it into dictionary).

Your problem seems to be that mechanize don't interpret JavaScript because your script looks right.

Bye!








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
• I Need Help
• User input validation
• Create a wrapper for a COM Dll
• HashMaps
• HashMaps
• NEED HELP! Urgent
• Re: Exciting Open Source Project in C++
• Re: The Ballarat Airline Company (BAC)
• Re: problem getting prompt window to work on IE


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008