Last active
January 7, 2021 17:01
-
-
Save gjtorikian/baff38c0c110774ca4695a75f5369a50 to your computer and use it in GitHub Desktop.
Is there new info on MacRumors yet
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/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