Skip to content

Instantly share code, notes, and snippets.

@lopnor
Created June 17, 2010 08:07
Show Gist options
  • Select an option

  • Save lopnor/441830 to your computer and use it in GitHub Desktop.

Select an option

Save lopnor/441830 to your computer and use it in GitHub Desktop.
#!perl
use strict;
use warnings;
use URI;
use Web::Scraper;
use HTML::Element;
use YAML;
my $rdfa = scraper {
process '//link[@rel="alternate"][@media="handheld"]', 'mobile', '@href';
process '//div[@typeof=~/^v:/]', 'rdfa[]', sub {
my $elem = shift;
my @elems = $elem->look_down('property', qr/^v:/);
return map { +{$_->attr('property') => $_->as_text } } @elems;
};
}->scrape(URI->new(shift));
warn Dump $rdfa;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment