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

I'm trying to grab some text from a website. The text in question lies between "" and "" tags. I've used LWP to grab links and images off of website like this but modifying my code for this doesn't seem to work. Any suggestions?

Replies are listed 'Best First'.
Re: Parsing Text from website
by chromatic (Archbishop) on Apr 24, 2000 at 18:58 UTC
    The <strong> tag, I guess? A regex which will handle only the simplest cases might be:
    if ($result =~ m!<strong>(.*?)</strong>!) { $text = $1; }
    For more complex and robust matches, the CPAN modules HTML::TokeParse, HTML::SimpleParse, and HTML::Parser will come in handy.
      Well put! I hadn't noticed the quotes had been bolded out too. He probably wrote "<strong>" and "</strong>"...

      Cheers!
Re: Parsing Text from website
by BBQ (Curate) on Apr 24, 2000 at 17:50 UTC
    Could you give an example of what it is you're trying to grab? Would "this" and "that" be a safe example? See if this works for you:
    $str = 'I know "This" and "That" but I want to know more...'; if ($str =~ m/(\".+?\" and \".+?\")/i) { print "Found: $1\n"; } ^d Found: "This" and "That"

    #!/home/bbq/bin/perl
    # Trust no1!