CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Text Extraction



Nov 13, 2005, 4:20 AM

Post #1 of 2 (766 views)
Text Extraction Can't Post

I have written a small Perl script that uses LWP::Simple to extract the source code of a web page into variable $content.

The web page contains information on the current exchange rate of the Euro against various currencies and I need to be able to extract the relevant value for British pounds.

About halfway down the page in a 3-column table you can find:

GBP Pound sterling 0.671

Can anyone advise what code / module I now need to use to grab this piece of information.

The actual code I have used is as follows:


use CGI;
use CGI::Carp qw(fatalsToBrowser);
use LWP::Simple;

my $content=get("");

print "Content-type: text/html\n\n";

print $content;

$content prints the whole page - I need to locate Pound sterling and extract the value (0.671 or whatever the current exchange rate is) so I can use that against my web site page calculations


Thaumaturge / Moderator

Nov 14, 2005, 4:04 AM

Post #2 of 2 (763 views)
Re: [AlanB] Text Extraction [In reply to] Can't Post

You'll need to use HTML::Parser or one of its subclasses. I usually usually use HTML::TreeBuilder, but in this case HTML::TableExtract might be more appropriate.

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives