HTML::Parser for example.
If you look at the source of the web-page you see that the latest update is within <kilauea_update>-tags, so all you have to do is extract the text between these tags.
Of course you may wish to save the the text in a variable or file. That is left as an exercise for the reader.use strict; use HTML::Parser (); use LWP::Simple; my $url="http://volcano.wr.usgs.gov/hvostatus.php"; my $mypage=get($url); # Create parser object my $grab_text = 0; my $p = HTML::Parser->new( api_version => 3, start_h => [\&kilauea_update_tag_start, "tag"] +, end_h => [\&kilauea_update_tag_end, "tag"] +, text_h => [\&textgrabber, "dtext +" ], ); $p->parse($mypage); sub kilauea_update_tag_start { my $tag = shift; return unless $tag eq 'kilauea_update'; $grab_text = 1; } sub kilauea_update_tag_end { my $tag = shift; return unless $tag eq '/kilauea_update'; $grab_text = 0; } sub textgrabber { my $text = shift; print $text if $grab_text and $text=~/Activity Summary for last 24 + hours:/; }
Update: The reason (amongst others) why your regex did not work is because the web-page has a lot of spurious linefeeds and other strange white-space embedded.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to Re: Basic search question
by CountZero
in thread Basic search question
by colonelcrayon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |