Skip to content

Instantly share code, notes, and snippets.

@gjtorikian
Last active January 7, 2021 17:01
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 gjtorikian/baff38c0c110774ca4695a75f5369a50 to your computer and use it in GitHub Desktop.
Save gjtorikian/baff38c0c110774ca4695a75f5369a50 to your computer and use it in GitHub Desktop.
Is there new info on MacRumors yet
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
model = 'MacBook_Pro_16'
url = "https://buyersguide.macrumors.com/\##{model}"
doc = Nokogiri::HTML(URI.open(url))
laptop_section = doc.search("//div[contains(@id,'#{model}')]/div[2]/div[2]/div")
puts "#{url}\n\n"
results = laptop_section.children.map do |child|
date = child.at('strong').text
content = child.search('a[1]')[1].text
link = child.search('a[1]')[1].attr('href')
"#{date}: #{content}\n#{link}"
end
puts results.join("\n\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment