Skip to content

Instantly share code, notes, and snippets.

@merrillcook0
Created December 15, 2020 23:16
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 merrillcook0/0f298ef461b0c38a5c623d9baf47bcd7 to your computer and use it in GitHub Desktop.
Save merrillcook0/0f298ef461b0c38a5c623d9baf47bcd7 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
html_data = open('https://www.nytimes.com/2020/06/15/technology/restaurants-coronavirus.html').read
nokogiri_object = Nokogiri::HTML(html_data)
related_posts = nokogiri_object.css("div.recirculation > h3 > a")
related_posts.each do |related_post|
puts related_post.text
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment