I'm using WWW::Mechanize::Firefox to login into a website that has a javascript heavy login process to access members only content. After the login the members content is mainly HTML. Mechanize::Firefox works for the login process but is painfully slow at scraping the site and I therefore want to use www::mechanize to do the main scraping job by using the same firefox session as I need to access the members content that I can only get when I am logged-in. I've had a go at this but it driving me mad. I'm not getting any of the members content when I switch the user agent to mechanize. Any ideas?

use WWW::Mechanize; use WWW::Mechanize::Firefox; # open firefox my $firefox = WWW::Mechanize::Firefox->new( create =>1, activate=>1, launch=>'/usr/bin/firefox', ); # stop timeout issues with firefox telnet my $url='some url'; my $new_timeout=100000; $firefox->repl->repl->client->{telnet}->timeout($new_timeout); $firefox->get($url); # log-in process $firefox->click({xpath=>'//*[@id="signInLink"]'}); sleep 60; my $username='username'; my $password='password'; # sign-in process $firefox->form_id('sign-in-form'); $firefox->set_visible($username, $password ); sleep 60; $firefox->click({xpath=>'//*[@id="button-sign-in"]'}); sleep 30; print "now logged-in\n"; # trying to get mechanize to use current mechanize::firefox session my $user_agent_name='Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:39.0) Ge +cko/20100101 Firefox/39.0'; my $agent = WWW::Mechanize->new(agent=>$user_agent_name); my $content = $agent->content(); print $content;

In reply to www::mechanize and www:mechanize::firefox by rmperl

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.