Hernan Lopes
and 1 contributors

NAME

WWW::Tabela::Fipe - Baixe a tabela fipe completa mantenha-se atualizado

SYNOPSIS

salve o trecho abaixo em um arquivo ex:

    vim fipe.pl

e coloque esse conteudo:

    package  WWW::Tabela::Fipe::Parser;
    use Moo;

    with('HTML::Robot::Scrapper::Parser::HTML::TreeBuilder::XPath'); 
    with('HTML::Robot::Scrapper::Parser::XML::XPath'); 

    sub content_types {
        my ( $self ) = @_;
        return {
            'text/html' => [
                {
                    parse_method => 'parse_xpath',
                    description => q{
                        The method above 'parse_xpath' is inside class:
                        HTML::Robot::Scrapper::Parser::HTML::TreeBuilder::XPath
                    },
                }
            ],
            'text/plain' => [
                {
                    parse_method => 'parse_xpath',
                    description => q{
                        esse site da fipe responde em text/plain e eu preciso parsear esse content type.
                        por isso criei esta classe e passei ela como parametro, sobreescrevendo a classe 
                        HTML::Robot::Scrapper::Parser::Default
                    },
                }
            ],
            'text/xml' => [
                {
                    parse_method => 'parse_xml'
                },
            ],
        };
    }

    1;

    package FIPE;

    use HTML::Robot::Scrapper;
    use CHI;
    use HTTP::Tiny;
    use HTTP::CookieJar;

    my $robot = HTML::Robot::Scrapper->new (
        reader    => {                                                       # REQ
            class => 'WWW::Tabela::Fipe',
        },
        writer    => {class => 'WWW::Tabela::FipeWrite',}, #REQ
        benchmark => {class => 'Default'},
    #   cache     => {
    #       class => 'Default',
    #       args  => {
    #           is_active => 0,
    #           engine => CHI->new(
    #                   driver => 'BerkeleyDB',
    #                   root_dir => "/home/catalyst/WWW-Tabela-Fipe/cache/",
    #           ),
    #       },
    #   },
        log       => {class => 'Default'},
        parser    => {class => 'WWW::Tabela::Fipe::Parser'},  #custom para tb fipe. pois eles respondem com Content type text/plain
        queue     => {class => 'Default'},
        useragent => {
            class => 'Default',
            args  => {
                ua => HTTP::Tiny->new( cookie_jar => HTTP::CookieJar->new),
            }
        },
        encoding  => {class => 'Default'},
        instance  => {class => 'Default'},
    );

    $robot->start();

depois, é só executar, ex:

    perl -I/home/catalyst/HTML-Robot-Scraper/lib/ -I./lib/ fipe.pl

o comando acima vai usar uma versao local do HTML-Robot-Scrapper.... se vc tiver instalado vc pode executar assim:

    perl fipe.pl

espero que gostem

DESCRIPTION

    Este módulo baixa a tabela FIPE atualizada para motos caminhoes e carros.  Direto do site da FIPE.
    Fonte: fipe.org.br

    Downloads the FIPE table updated directly from fipe source.
    DataSource: fipe.org.br

AUTHOR

    HERNAN
    CPAN ID: HERNAN
    perldelux
    hernan@cpan.org
    http://github.com/hernan604

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

perl(1).

1 POD Error

The following errors were encountered while parsing the POD:

Around line 324:

Non-ASCII character seen before =encoding in 'é'. Assuming UTF-8