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(); }
In reply to WWW::Mechanize agent timing-out from server by cheech
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |