donfreenut has asked for the wisdom of the Perl Monks concerning the following question:


This may be an inordinately stupid question.

I'm getting a webpage with LWP::UserAgent, and I want to look for a string in the response. What's the fastest/best way to do this?

Replies are listed 'Best First'.
Re: Finding a string in a webpage
by arturo (Vicar) on Jan 30, 2001 at 01:31 UTC

    Alternative: use lynx -dump [url] and search through that with a regex. That way you don't run into messy issues of whether the text is part of a tag or not.

    You can also, if you're doing a complexish search, employ HTML::Parser or one of its subclasses in such a routine.

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: Finding a string in a webpage
by KM (Priest) on Jan 30, 2001 at 01:28 UTC
    Use a regular expression. Read perlre, and Mastering Regular Expressions.

    Cheers,
    KM