my $fecha_tramite_min = '24/11/2024'; my $fecha_tramite_max = '27/11/2024'; my $fecha_matricula_min = '01/01/1900'; my $fecha_matricula_max = '31/12/2000'; # ... if ($fecha_tramite ge $fecha_tramite_min && $fecha_tramite le +$fecha_tramite_max && $fecha_matricula ge $fecha_matricula_min && $fecha_matricu +la le $fecha_matricula_max && $prov_matriculacion eq $prov_matriculacion_filtro) {

At least one of the problems is that you are comparing dates lexically. This will not work at all where the least significant part of the date (the day of the month) comes first. eg. in your current code, any $fecha_tramite which is the 25th or 26th of any month of any year will match which is presumably not what you want.

There are any number of ways to solve this. I would reach for Time::Piece, convert all the dates into Time::Piece objects and then use the less-than and greater-than operators (< and >) to compare them.

Looking at the big picture, ensure that you have the right to extract these data sets in the first place. And if you do, consider searching for an API which would be less brittle than parsing HTML for the results.


🦛


In reply to Re: Script to scrape data by hippo
in thread Script to scrap data by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.