Skip to content

Instantly share code, notes, and snippets.

@davorg
Last active December 13, 2018 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davorg/b059cfffd2592be865676b28374b8f1a to your computer and use it in GitHub Desktop.
Save davorg/b059cfffd2592be865676b28374b8f1a to your computer and use it in GitHub Desktop.
Scraping the NME's top 100 albums of 2018
#!/usr/bin/perl -CS
use strict;
use warnings;
use utf8;
use feature 'say';
use Web::Query;
my $page = 'https://www.nme.com/blogs/nme-blogs/' .
'best-greatest-albums-of-the-year-2018-2419656';
wq($page)
->find('h2')
->each(sub {
my $line = $_->text;
return unless $line =~ /^\d+\./;
my ($num, $artist, $title) = $line =~ /^(\d+)\.\s(.+) – ‘(.+)’/;
say join "\t", $num, $artist, $title;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment