in reply to Pulling HTML off another site problem
First pointer, use strict! Then you see that you really want:
instead of assigning the output of get() to $_.my $data = get . . . . $data =~ . . . .
Here, try this:
$wanted should have what you want. Use \s instead of a litteral space. \s catches newlines and tabs as well. Also, you need the 's' modifier instead of 'm'.#!/usr/bin/perl -w use strict; use LWP::Simple; my $data = get ("http://www.bloomberg.com/energy/index.html"); my ($wanted) = $data =~ /<!-+PETROLEUM-+>\s*(.*)\s*<map\s+name="BbgELo +gin2">/s; open (FH,'>file.txt') || die $!; # > creates a new file, >> appends print FH $wanted; close FH; # not really necessary in this simple script
I recommend you use a parser, such as HTML::Parser, or possibly HTML::TokeParser. It takes a little time to learn the interface to these modules, but that time is well invested, as you will ultimately save more time and hair.
Jeff
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Pulling HTML off another site problem
by ChemBoy (Priest) on Jun 23, 2001 at 23:58 UTC | |
by cLive ;-) (Prior) on Jun 24, 2001 at 01:08 UTC |