Skip to content

Instantly share code, notes, and snippets.

@Papillard
Created August 17, 2016 16:12
Show Gist options
  • Save Papillard/04e99cab064fadcbbf0ff8be54ec84a5 to your computer and use it in GitHub Desktop.
Save Papillard/04e99cab064fadcbbf0ff8be54ec84a5 to your computer and use it in GitHub Desktop.
TimeOut best pubs scraper
require "open-uri"
require "nokogiri"
url = "http://www.timeout.com/london/bars-and-pubs/the-100-best-bars-and-pubs-in-london"
html_file = open(url)
doc = Nokogiri::HTML(html_file)
doc.search(".feature-item").each do |bar|
p bar.search("img")[0].attr("src")
p bar.search("h3 a")[0].text
p bar.search(".listings_flag")[0].text.strip
puts "*" * 50
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment