Skip to content

Instantly share code, notes, and snippets.

@xaiki
Forked from ahmdrefat/kiosko_scraper.rb
Created April 8, 2018 21:25
Show Gist options
  • Save xaiki/20ec7e8e8834c1ae7bfd926e8dc8e91a to your computer and use it in GitHub Desktop.
Save xaiki/20ec7e8e8834c1ae7bfd926e8dc8e91a to your computer and use it in GitHub Desktop.
Scraping newspapers names from kiosko
require 'open-uri'
require 'nokogiri'
home_page = Nokogiri::HTML(open('http://en.kiosko.net/'))
countries = {}
cities = {}
newspapers = []
home_page.css("#menu a").each do |a|
puts countries[a.content] = "http://en.kiosko.net" + a.attributes["href"].value
#links << a.attributes["href"].value
end
countries_newspapaer = {}
countries.each do |value, key|
country_page = Nokogiri::HTML(open(key))
country_page.css(".line li a img").each do |img|
puts img.attributes["alt"].value
countries_newspapaer[value] = img.attributes["alt"].value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment