cheech has asked for the wisdom of the Perl Monks concerning the following question:
The problem is, I always get disconnected from the server eventually. Sometimes it's after 6 months, and sometimes 4 years. I think this may be a problem with the internet configuration here in my school apartment (I made it through 50 years at home last week), though I don't know how to check/remedy that.
How can I modify the block below to restart the loop at the current iteration whenever disconnection occurs?
Thanks!
use WWW::Mechanize; use Fortran::Format; my $mech = WWW::Mechanize->new(); $mech->get($url); foreach my $date (@dates) { $mech->form_number(1); $mech->field('dtg',"$date"); $mech->click(); my $page = $mech->content(format=>'text'); my @data = ($page =~ /:\s\s\s\s(\d\d)/g); my @rain = ($page =~ /Rain or Liquid Equivalent\s+:\s+(\S*)/); my @snow = ($page =~ /Snow and\/or Ice Pellets\s+:\s+(\S*)/); my @depth = ($page =~ /Snow Depth\s+:\s+(\S*)/); my @hdd = ($page =~ /Degree-Days\s+:\s+(\S*)/); my $f = Fortran::Format->new("(I2.1,2X)")->write($hdd[0]); @hlahdd = ("$date $data[0] $data[1] $data[2] $f"); print "@hlahdd"; print FH "@hlahdd"; sleep .1; $mech->back(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::Mechanize agent timing-out from server
by SuicideJunkie (Vicar) on Jul 28, 2009 at 20:48 UTC | |
by cheech (Beadle) on Jul 28, 2009 at 21:10 UTC | |
by SuicideJunkie (Vicar) on Jul 28, 2009 at 21:15 UTC | |
by cheech (Beadle) on Jul 28, 2009 at 22:04 UTC | |
by Anonymous Monk on Jul 29, 2009 at 00:06 UTC | |
by SuicideJunkie (Vicar) on Jul 29, 2009 at 12:11 UTC | |
by cheech (Beadle) on Jul 29, 2009 at 21:42 UTC | |
by Anonymous Monk on Jul 30, 2009 at 01:21 UTC | |
|
Re: WWW::Mechanize agent timing-out from server
by Anonymous Monk on Jul 28, 2009 at 22:02 UTC |