in reply to Re: problem login using WWW::Mechanize
in thread problem login using WWW::Mechanize

Really thanx... lot

But dude can you tell me , how can i remember cookies? this is very important because, i want to extract meta data's ( title, Genre, ...and torrent url .torrent) for a particular movie and this has to be in loop . I have the code to do so, Now the question is it asks (bittorrent) user name and password every time i entered rented page, If you are using a browser then once you login then browser remembers the cookies and you need not to login again and again... and you can enter any page and access any content. I just want the same task to be automated. I have the code that does all automation but i have stuckked in Login and remembering cookies please can you siggest me.... you can also mail me @ shekarkcb@gmail.com Thanx, Shekar

  • Comment on Re^2: problem login using WWW::Mechanize

Replies are listed 'Best First'.
Re^3: problem login using WWW::Mechanize
by Anonymous Monk on Jun 10, 2008 at 07:34 UTC
    Thats what a cookie_jar is for
      Thanx Again...

      So you mean to say that the below code examples the same right?


      
      use HTTP::Cookies;
      use WWW::Mechanize;
      
      my $cookiefile = 'cookies.txt';
      my $cookie_jar = HTTP::Cookies->new(File => $cookiefile, autosave =>1);
      my $m = WWW::Mechanize->new( autocheck => 1 );
      $m->cookie_jar($cookie_jar);
      my $url="https://www.bittorrent.com/account/signin";
      $m->get($url);
      $m->submit_form(
            form_number => 2,
            fields      => {
               username    => 'abcd',
               password    => 'abcd',
            }
      );
      
      
      my $content= $m->content;
      
      

      and from now you can use $m to do any thing i mean to say can i use $m to get content of any linked page inside the login page ??? something like this??

      if($content =~ m/<li id=\"movies\"><a href=\"(.*?)\" title=\"Movies\"> +Movies<\/a><\/li>/i) { my $movie = $1; $m->get($movie); my $content_1 = $m->content; if($content_1 =~ m/<h3><a href=\"(.*?)\" title=\"\">Browse All +<\/a><\/h3>/i) { my $movie_1 = $1; $movie_1 \n"; $m->get($movie_1)||die ("\nCan't Get the Browse URL\n" +); my $content_2 = $m->content; if($content_2 =~ m/<li><a href=\"(.*?)\">Rent<\/a><\/l +i>/i) { my $movie_2 = $1; $movie_2=~ s/&amp;/&/g; $m->get($movie_2)||die("\nCant Get The Rent UR +L\n"); $content_3 = $m->content; } } else { print "Not Matched Rent URL\n"; } } else { print "\nSorry Not Matched Browse All\n"; }} else { print "\nNot matched Movie page\n"; }

      So If any thing requires in $content_3 page requires a authentication then will my code 2ndpartremembers the earlier cookies as i have coded above see Ist part Please suggest me ....



      Thanx, Shekar
      Thanx Again...

      So you mean to say that the below code examples the same right?


      
      use HTTP::Cookies;
      use WWW::Mechanize;
      
      my $cookiefile = 'cookies.txt';
      my $cookie_jar = HTTP::Cookies->new(File => $cookiefile, autosave =>1);
      my $m = WWW::Mechanize->new( autocheck => 1 );
      $m->cookie_jar($cookie_jar);
      my $url="https://www.bittorrent.com/account/signin";
      $m->get($url);
      $m->submit_form(
            form_number => 2,
            fields      => {
               username    => 'abcd',
               password    => 'abcd',
            }
      );
      
      
      my $content= $m->content;
      
      

      and from now you can use $m to do any thing i mean to say can i use $m to get content of any linked page inside the login page ??? something like this??

      if($content =~ m/<li id=\"movies\"><a href=\"(.*?)\" title=\"Movies\"> +Movies<\/a><\/li>/i) { my $movie = $1; $m->get($movie); my $content_1 = $m->content; if($content_1 =~ m/<h3><a href=\"(.*?)\" title=\"\">Browse All +<\/a><\/h3>/i) { my $movie_1 = $1; $movie_1 \n"; $m->get($movie_1)||die ("\nCan't Get the Browse URL\n" +); my $content_2 = $m->content; if($content_2 =~ m/<li><a href=\"(.*?)\">Rent<\/a><\/l +i>/i) { my $movie_2 = $1; $movie_2=~ s/&amp;/&/g; $m->get($movie_2)||die("\nCant Get The Rent UR +L\n"); $content_3 = $m->content; } } else { print "Not Matched Rent URL\n"; } } else { print "\nSorry Not Matched Browse All\n"; }} else { print "\nNot matched Movie page\n"; }

      So If any thing requires in $content_3 page requires a authentication then will my code 2ndpartremembers the earlier cookies as i have coded above see Ist part Please suggest me ....



      Thanx, Shekar