Skip to content

Instantly share code, notes, and snippets.

@ahmdrefat
Created June 28, 2012 08:28
Show Gist options
  • Select an option

  • Save ahmdrefat/3009908 to your computer and use it in GitHub Desktop.

Select an option

Save ahmdrefat/3009908 to your computer and use it in GitHub Desktop.

Revisions

  1. ahmdrefat created this gist Jun 28, 2012.
    24 changes: 24 additions & 0 deletions kiosko_scraper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    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