Hi mserino,
While you could certainly get at an individual element of the list returned, it would be cumbersome to access it that way in your example page, where there are more than 600 <p> tags. I think you would be better served searching for a match in the paragraphs you want. Here's an example:
Output:#!/usr/bin/perl use strict; use warnings; use feature qw/ say /; use Data::Dumper; use WWW::Mechanize; use WWW::Mechanize::TreeBuilder; my $mech = WWW::Mechanize->new(); WWW::Mechanize::TreeBuilder->meta->apply($mech); $mech->get("http://millercenter.org/president/clinton/oralhistory/roge +r-altman"); for ( $mech->look_down(_tag => 'p') ) { next unless $_->as_trimmed_text =~ m/a haircut in California/; say $_->as_HTML; } __END__
<p>The election occurred and about a week later Reagan was getting a h +aircut in California and he came out of the barbershop. There had bee +n some minor event that day and he was asked what he thought of the l +atest developments in Iran and he said, <q>I don’t talk about b +arbarians.</q>
No problem to build up a list of paragraphs and push them onto your output, then get some other content. You can definitely do it in one program. Hope this helps!
In reply to Re: Extracting specific <p>content</p> using WWW::Mechanize
by 1nickt
in thread Extracting specific <p>content</p> using WWW::Mechanize
by mserino
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |