Sunday September 09, 2007
11:52 AM
Web::Scraper hacks #2: Extract javascript and css content
This is inspired by an email from Renée Bäcker
asking how to get content inside javascript tag. Because Web::Scraper's 'TEXT' mapping calls as_text method of HTML::Element, it doesn't get the content inside script and style tag.
Here's the code that works. It's kinda clumsy, and it'd be nice if there's much cleaner way to do this:
#!/usr/bin/perl
# extract Javascript code into 'code'
use strict;
use Web::Scraper;
my $s = scraper {
process "script", code => sub {
join '', $_->content_list;
};
};
Web::Scraper hacks #2: Extract javascript and css content 0 Comments More | Login | Reply /