It seems that you were fighting two problems. One I can't easily fix - it seems that MozRepl::Client does not like getting instantiated twice. You can fix that by only ever using one instance of WWW::Mechanize::Firefox, outside of your loop. The second problem is that Firefox does not fire the proper events when moving to a new URL, if the new URL only differs in the anchor part from the old URL. I've changed your program to simply do two ->get() calls, one to about:blank to flush the current page, and then one again to the new real URL.

I've also removed the use Date::Manip statement, as it wasn't used at all. There was $j used as a counter but incremented in two places. I've removed the explicit increment. The HTML extraction seemed easier when done using the ->selector() method of WWW::Mechanize::Firefox.

Here is the program that works for me:

#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize::Firefox; use WWW::Mechanize; use DateTime; my ($firemech) = WWW::Mechanize::Firefox->new(); my $count; while($count++ < 2){ my $nick = <DATA>; chomp $nick; #my $j = 0; for my $j(0..3){ my ($date) = DateTime->now; my ($k) = 0; while($k < $j){ $date = $date->subtract( days => 7); $k++; } $date = $date->ymd; $firemech->get('about:blank'); my $url = "http://www.quakelive.com/#profile/matches/$nick/$da +te"; $firemech->get($url); die "Cannot connect to $url\n" if !$firemech->success(); my ($retries) = 10; while ($retries-- and ! $firemech->is_visible( xpath => '//*[@ +class="areaMapC"]', all => 1 )) { sleep 1; } die "Timeout" unless $retries; my ($content) = $firemech->content(); while(($content =~ /class="areaMapC" id="([^<]+)_([^<]+)_([^<] ++)">/gsi)){ my ($game) = $1; my ($longid) = $2; my ($shortid) = $3; my ($matchid) = "$longid/$game/$shortid\n"; print $matchid; }; my @areaMapC = $firemech->selector('.areaMapC'); print $_->{id},"\n" for @areaMapC; #$j++; } } undef $firemech; __DATA__ peavey trajan komap bluedawg donpidon x9rcist dom_prova_____ newton burn tyryl st1mz tomo32 zky hisarrzulu _luk__47_ sendhu joopsta sand5pid3r trickle mikenoid beg1nner fladder72 4bsan1ty daitarn z0id0uf amoreno stuntt askkk flyttadig arcsign glavic acid_predator new_0 jala1 crucci niko95 deputydawg optixx ennesit martianbuddy b4r r1dah gathion function9 chup4 poocamshot shnipzr heppo b4byb34r the_hulk

In reply to Re^7: MozRepl cleanup problem by Corion
in thread MozRepl cleanup problem by giantpanda

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.