in reply to Re: Find a specific word in a text file
in thread Find a specific word in a text file

Thanks for the help Dave. I've tried it
use LWP::Simple; my $page = get("http://www.google.de"); if ( ( my $position = index $page, "font-family" ) >= 0 ) { print "Found at $position.\n"; }
but did not produce any results even though the souce from the page contains:
</title><style><!--body,td,a,p,.h{font-family:arial,sans-serif;}

Replies are listed 'Best First'.
Re^3: Find a specific word in a text file
by davido (Cardinal) on Sep 09, 2004 at 08:13 UTC

    Be sure to do as is described in the POD for LWP::Simple: Check your return values for success.

    my $page = get("http://www.whoever.de"); die "Couldn't get the page!\n" unless defined $page;

    It could be that you're not even succeeding in fetching the page. Next, dump $page into a text file where you can examine it later to see if it really contains the text you're looking for (without any line-breaks, etc). If your HTML parsing needs get fairly elaborate, you might want to look at HTML::TokeParser anyway; use a powertool when a powertool is needed.


    Dave

      Thanks for your help Dave. TokeParser was a great Idea. It took a while but I got it working now. Thx.