Skip to content

Instantly share code, notes, and snippets.

@paulmars
Last active October 24, 2015 18:11
Show Gist options
  • Select an option

  • Save paulmars/ada07e7e90abce876bfe to your computer and use it in GitHub Desktop.

Select an option

Save paulmars/ada07e7e90abce876bfe to your computer and use it in GitHub Desktop.
Pitchfork best new music
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