Last active
October 24, 2015 18:11
-
-
Save paulmars/ada07e7e90abce876bfe to your computer and use it in GitHub Desktop.
Pitchfork best new music
This file contains hidden or 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
| require 'net/http' | |
| require 'nokogiri' | |
| require 'awesome_print' | |
| url = "http://pitchfork.com/reviews/best/albums/" | |
| uri = URI(url) | |
| html_doc = Nokogiri::HTML(Net::HTTP.get(uri)) | |
| albums = html_doc.css(".bnm-list li") | |
| ap albums | |
| good_albums = albums.map{|a| a.css(".score") } | |
| def clean(element) | |
| [ | |
| element.css("h1").last.text, | |
| element.css("h2").text | |
| ] | |
| rescue | |
| nil | |
| end | |
| good_albums = albums.map{|a| clean(a) }.compact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment