| WWW-CBF documentation | Contained in the WWW-CBF distribution. |
WWW::CBF - Brazilian Football Championship status
Version 0.01
use WWW::CBF;
my $ranking = WWW::CBF->new();
my $lider = $ranking->pos(1);
print $lider->{clube} . "\n"
. $lider->{pontos} . "\n"
. $lider->{jogos} . "\n"
. $lider->{vitorias} . "\n"
. $lider->{derrotas} . "\n"
. $lider->{empates} . "\n"
. $lider->{gp} . "\n" # gols pro
. $lider->{gc} . "\n" # gols contra
. $lider->{sg} . "\n" # saldo de gols
. $lider->{ap} . "\n" # aproveitamento
;
Este módulo oferece uma interface simples com os dados do site www.cbf.com.br, espeficicamente em relação ao Campeonato Brasileiro (a.k.a. "Brasileirão").
This module provides a simple scraping interface to www.cbf.com.br and its data, mainly the Brazilian Football (soccer) Championship.
Cria uma nova instância do objeto, contento a classificação atual. Nesta versão apenas dados da série A do campeonato são obtidos.
Creates a new object instance, containing current championship ranking. In this version only A series (highest division) data is obtained.
Retorna um hash com informações a respeito do clube na devida posição do campeonato. Os valores do hash estão descritos na sinopse.
Returns a hash with information regarding the club in the given position on the championship. Hash values are described on the synopsis.
Realiza nova busca no site e obtém valores atualizados.
Scrapes the site again and gets updated values.
Breno G. de Oliveira, <garu at cpan.org>
Please report any bugs or feature requests to bug-www-cbf at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-CBF. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc WWW::CBF
You can also look for information at:
Agradecimentos especiais à Confederação Brasileira de Futebol (CBF) por fornecer os dados atualizados do campeonato em seu site.
Special thanks to the Brazilian Football Confederation (CBF) for providing the updated championship data on its website.
Copyright 2009 Breno G. de Oliveira, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| WWW-CBF documentation | Contained in the WWW-CBF distribution. |
package WWW::CBF; use URI; use Web::Scraper; eval 'use HTML::TreeBuilder::LibXML'; use warnings; use strict; our $VERSION = '0.01'; my $cbf = scraper { process 'tr', 'clubes[]' => scraper { process 'td', 'dados[]' => 'TEXT'; }, }; sub new { my $class = shift; my $self = {}; bless $self, $class; $self->reload; return $self; } sub reload { my $self = shift; my $url = 'http://www.cbf.com.br/seriea/indexa.html'; my $site = $cbf->scrape( URI->new($url) ); my $pos = -1; foreach my $clube ( @{$site->{clubes}} ) { next if ++$pos == 0; # first entry contains just table fields # get values from scraper $self->{$pos} = { clube => $clube->{dados}->[1], pontos => $clube->{dados}->[2], jogos => $clube->{dados}->[3], vitorias => $clube->{dados}->[4], gp => $clube->{dados}->[5], gc => $clube->{dados}->[6], sg => $clube->{dados}->[7], ap => $clube->{dados}->[8], }; # infer other values from championship rules $self->{$pos}->{empates} = $self->{$pos}->{pontos} - ($self->{$pos}->{vitorias} * 3) ; $self->{$pos}->{derrotas} = $self->{$pos}->{vitorias} - $self->{$pos}->{empates} ; } return $self; } sub pos { my $self = shift; my $pos = shift; return $self->{$pos}; } 42; __END__