I was working on the Yahoo search interface problem at Rosetta Code, and came up with the following:
use Gumbo;
use LWP::Simple;
my $dom = parse-html( LWP::Simple.get("http://search.yahoo.com/search?p=test") );
my @r = $dom.lookfor( TAG => "h3", class => "title");
for @r {
.lookfor( TAG => "a" ).map({ [ .attribs<href>, .contents[0] ] }).say;
my $desc = .parent.parent.lookfor( TAG => "div" )[1];
$desc.nodes.map( *.contents ).say
};
$dom.lookfor( TAG => "a", class => "next").say
It's mostly straight-forward until I try to pull the text out of the node in $desc...then it becomes problematic.
I've noticed that a lot of things are a bit wonky with Perl6's XML module, and the author looks to be fairly
inactive. Unfortunately, Gumbo is tied to it. XML really could use a text
method. I will see if I can write one...