Last active
December 13, 2018 16:24
-
-
Save davorg/b059cfffd2592be865676b28374b8f1a to your computer and use it in GitHub Desktop.
Scraping the NME's top 100 albums of 2018
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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