Happy Turkey Day fellow monks!

I am currently trying to learn spanish. I found a website that has a page that displays a new spanish word each day.

I would like to write a script that I can have cron run that will download the web page, parse the spanish word for the day and email mail it to me so that I can download it to my palm pilot.

Not a difficult task I know. The only part Im not to sure about is if Im parsing the data properly. Im am inexperienced with regular expressions, so would like fellow monks suggestions.

An example of the html src:

.... SNIP ..... if (day == 22) document.write("<p><font size='+2'><font color='#cc0000 +'><i><b>acongojar:</b></i></font> to sadden or grieve. <i>Mi hermano +estaba muy acongojado cuando muri&oacute\; su esposa</i>, my brother +was very sad when his wife died.</font>"); if (day == 23) document.write("<p><font size='+2'><font color='#cc0000 +'><i><b>contestar:</b></i></font> to answer. <i>Sus oraciones fueron +contestadas</i>, her prayers were answered.</font>"); .... SNIP ....

I have written a quick script to download and print out the data but am unsure if I should do things differently. It appears to work.

Test perl script

#!/usr/bin/perl -Tw use strict; use LWP::Simple; my $url = 'http://spanish.about.com/homework/spanish/blword.htm'; die "Unable to download Spanish word of the day." unless (defined(my $ +web = get ($url))); my $today = ((localtime)[3]); print "\nToday: $today\n"; my ($word, $def, $sent, $trans) = $web =~ m[if \(day == $today\).+?<b> +(\w+):</b></i></font>(.+?)<i>(.+?)</i>,(.+?).</font>]s; print "Word: $word\nDefinition: $def\nSentence: $sent\nTranslation: $t +rans\n";

Thanks for any suggestions!
zzSPECTREz


In reply to Patern matching html. by zzspectrez

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.