I need to get the content of "p" tag, that contents each of the seven paragraphs of my text, and, separately, the content of the "recording dates" (h4 and h3) tag, that contents the text title. "p" and "recording dates" belong to "release-height". The problem is that they are on the same level. So I don't know how to get them separately. I need to do two process, on for the "name of the artist", and the title of the artist, and one another for all of the paragraphs, but i really don't know how to proceed.
use URI;
use Web::Scraper;
use Encode;
use Data::Dumper;
open (OUT, '>LM_Article.txt');
my $resultat = scraper
{
process '//body[@id="artists"]', 'entree[]' => scraper
{
process '//div[@class="header-bar-inner"]/h2', artiste => 'TEXT';
process '//div[@class="release-height"]/div[@class="recording-
+ dates"]', titre => 'TEXT';
};
my $resultat2 = scraper
{
process '//div[@class="release-height"]', 'entree[]' => scraper
+
{
process '//div[@class="release-height"]/p', texte =>'TEXT';
};
}
my $res = $resultat.$resultat2 ->scrape( URI- >new("http://www.bluen
+ote.com/artists/lee-morgan") );
for my $val (@{$res->{entree}})
{
print OUT Encode::encode ("utf8", $val->{artiste} . "\n" . $val->
+ {titre} . "\n" . $val->{texte} . "\n");
}
close (OUT);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.