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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Text Extraction

 



AlanB
Novice

Nov 13, 2005, 4:20 AM

Post #1 of 2 (647 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:

#!/usr/bin/perl

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

my $content=get("http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html");

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


Thanks
Alan


davorg
Thaumaturge / Moderator

Nov 14, 2005, 4:04 AM

Post #2 of 2 (644 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
http://www.dave.org.uk/
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