draper7 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w ## georgia cash 4, drawings every day. ## pretty good odds, not that i ever play. # use strict; use LWP::Simple; use HTML::TableExtract; use Date::Calc qw(Today Day_of_Week Add_Delta_Days Day_of_Week_to_Text Date_to_Text Date_to_Days Decode_Date_US); my @today = Today(); my $current_dow = Day_of_Week(@today); my @lotto_dates;
my $end_date; ## calculate what days there were lotto # my @prev_day = Add_Delta_Days(@today,0); ## # they started midday drawnings... $end_date = "2/5/2001\n"; for (;;) { @prev_day = Add_Delta_Days(@prev_day,-1); my ($sat_year,$sat_month,$sat_day) = Add_Delta_Days(@prev_day,0); my $sat_date = "$sat_month\/$sat_day\/$sat_year\n"; if ($sat_date eq $end_date) { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:M\n"); push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); last; } else { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:M\n"); push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); } } ## # theres no midday drawnings past this day... $end_date = "4/6/1997\n"; for (;;) { @prev_day = Add_Delta_Days(@prev_day,-1); my ($sat_year,$sat_month,$sat_day) = Add_Delta_Days(@prev_day,0); my $sat_date = "$sat_month\/$sat_day\/$sat_year\n"; if ($sat_date eq $end_date) { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); last; } else { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); } } ## # there are 131 dates on one page my @html; my $count = 131; foreach my $line (@lotto_dates) { if ($count == 131) { my $url = "http://www.georgialottery.com/lottery/win.cgi?game= +7&ten=yes&enddate=$line"; my $url_data = get $url; push(@html,$url_data); $count = 0; } $count++; } ## i shouldn't do this, should i? # open(HTML,">html.txt"); print HTML @html; close(HTML); ## extract table info from array # my $extract = new HTML::TableExtract( headers => ['Date','Numbers'] ); my $ts; my $row; undef $/; ## help? # open(HTML, "html.txt"); my $lotto = <HTML>; close(HTML); open(NUMBERS, ">c4_numbers.txt"); $extract->parse($lotto); foreach $ts ($extract->table_states) { foreach $row ($ts->rows) { print NUMBERS join(":", @$row), "\n"; } } close(HTML); close(NUMBERS);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Just Another Lotto Script
by ckohl1 (Hermit) on Mar 06, 2002 at 16:33 UTC | |
by draper7 (Scribe) on Mar 06, 2002 at 16:45 UTC | |
by Juerd (Abbot) on Mar 06, 2002 at 16:58 UTC | |
by draper7 (Scribe) on Mar 06, 2002 at 17:15 UTC | |
Re: Just Another Lotto Script
by scain (Curate) on Mar 06, 2002 at 16:10 UTC | |
by draper7 (Scribe) on Mar 06, 2002 at 16:34 UTC | |
by scain (Curate) on Mar 06, 2002 at 16:49 UTC | |
by Juerd (Abbot) on Mar 06, 2002 at 16:56 UTC | |
by draper7 (Scribe) on Mar 06, 2002 at 17:10 UTC |