Skip to content

Instantly share code, notes, and snippets.

@leedo
Created October 31, 2011 03:49
Show Gist options
  • Save leedo/1326871 to your computer and use it in GitHub Desktop.
Save leedo/1326871 to your computer and use it in GitHub Desktop.
Web::Scraper issue
#!/usr/bin/perl
use Web::Scraper;
use Data::Dump qw/pp/;
use File::Slurp;
my $html = read_file($ARGV[0]);
my $scraper = scraper {
process 'header#content', html => 'RAW';
process 'section h2', title => 'TEXT';
};
my $data = $scraper->scrape($html);
pp $data;
<!DOCTYPE html>
<html class="no-js" dir="ltr" lang="en">
<head>
<title>Screen Shot 2011-09-17 at 10.00.15.png</title>
</head>
<body id="image">
<header id="header">
<h1><a href="http://store.getcloudapp.com/">Simple sharing</a></h1>
<h2>Screen Shot 2011-09-17 at 10.00.15.png</h2>
<a class="embed" href="http://cl.ly/1f0u1C0Y2q310m3y0F1g/Screen_Shot_2011-09-17_at_10.00.15.png">Direct link</a>
</header>
<section id="content">
<img alt="Screen Shot 2011-09-17 at 10.00.15.png" src="http://cl.ly/1f0u1C0Y2q310m3y0F1g/Screen_Shot_2011-09-17_at_10.00.15.png">
</section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment