Hi monks who are always smarter than me.
I'm using Mojo::DOM in a script to try and parse several html files. I can return most of the text that I need but I have one piece of html that I can't seem to get.
Here's the html that I'm trying to pull:
<div class="abstract-content selected" id="enc-abstract">
<p>Secondary bile acids (BAs) and short chain fatty acids (SCFAs), two
major types of bacterial metabolites in the colon...
</p>
and here is the code that I've been trying to use. The commented out items are my many attempts at trying to get it to work and trying to look at some of my older code and other code out there.
#<div class="abstract-content selected" id="enc-abstract">
# my $abstr = $dom1->find('p[strong.class^="sub-title"]'
+)->map( sub{ $_->text } )->map( sub{ s|\n| |gr } );
#div[enc-abstract]
#'div["abstract-content selected" id^="enc-abstract"]'
#'div[class^="officerOuter officerInner"]
# $r2 = $dom2->find( '[class="1YTREF"]' ) -> map(
+sub{ $_->text } );
#my $abstr = $dom1->find('div[class^="abstract-content s
+elected"]')->map( sub{ $_->text } )->map( sub{ s|\n| |gr } );
# $dom->find('div.openTime')
# ->map(sub{$_->children->each})
# ->map(sub{$_->text})
# ->each;
# my $abstr = $dom1->at('abstract-content selected')
# ->find('p')
# ->map( sub{ $_->text } );
my $abstr = $dom1->find('div[class^="abstract-content se
+lected"]')->map( sub{ $_->text } )->map( sub{ s|\n| |gr } );
#my $abstr = $dom1->at('#abstract-content')->find('p')->ea
+ch(sub {
# $_; # this is the current element
# });
# my $abstr = $dom1->find('.abstract-content selected'
+)
# ->map(sub{$_->children->each})
# ->map( sub{ $_->text } );
# #->map( sub{ s|\n| |gr } );
# print "Abstract is: $abstr\n\n";
It's the code for the paragraph in html after the class that is messing things up I believe. I read the Mojo docs over and over and tried a few tings with child nodes but failed miserably.
Any help would be greatly appreciated. it's probably very simple and I was just overthinking it, up late and tired.</>