in reply to Re^6: MozRepl cleanup problem
in thread MozRepl cleanup problem
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: MozRepl cleanup problem
by giantpanda (Initiate) on Nov 02, 2010 at 12:42 UTC | |
by Corion (Patriarch) on Nov 02, 2010 at 16:23 UTC | |
by giantpanda (Initiate) on Nov 02, 2010 at 17:41 UTC | |
by Corion (Patriarch) on Nov 02, 2010 at 18:04 UTC | |
by giantpanda (Initiate) on Nov 02, 2010 at 18:55 UTC | |
|