Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: FreekKalter/WWW-Scraper-F1
base: 7128268489
...
head fork: FreekKalter/WWW-Scraper-F1
compare: 0bc68b51a0
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 31 additions and 9 deletions.
  1. +22 −0 example/example.pl
  2. +9 −9 lib/WWW/Scraper/F1.pm
22 example/example.pl
View
@@ -0,0 +1,22 @@
+use v5.14;
+use warnings;
+use strict;
+
+use Getopt::Long;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use WWW::Scraper::F1;
+
+my $upcoming = 1;
+my $top = -1;
+my $points = '';
+
+GetOptions(
+ 'upcoming!' => \$upcoming,
+ 'top:i' => \$top,
+ 'points=s' => \$points,
+);
+
+print get_upcoming( ) if ($upcoming);
+print get_top( {length => $top, points => $points} );
+
18 lib/WWW/Scraper/F1.pm
View
@@ -44,18 +44,15 @@ sub get_upcoming {
}
sub get_top {
- my %options = @_;
+ my $options = shift;
+ $options->{points} = $options->{points} || "yes";
+ $options->{length} = $options->{length} || 5;
my $total_info = &get_info;
my $championship_table = $total_info->{'championship_info'};
- my ( $top_length, $points) = @_;
my $output = '';
- #some defaults
- my $length = $options{top_length} ? $options{top_length} : 5;
- my $points_display = $options{points} ? $options{points} : 'yes';
-
- for ( my $i = 1 ; $i <= $length ; $i++ ) {
- given ($points_display) {
+ for ( my $i = 1 ; $i <= $options->{length} ; $i++ ) {
+ given ($options->{points}) {
when (/no/) {
$output .= sprintf( "%d %-20s\n",
$i, $championship_table->[$i]->{'driver'} );
@@ -191,4 +188,7 @@ WWW::Scraper::F1
=head1 SYNOPSIS
-Scrape info for upcoming race and current championship from formula1.com.
+ use WWW::Scraper:F1;
+
+ print get_upcoming_race([length => 5 , points => just]);
+

No commit comments for this range

Something went wrong with that request. Please try again.