Skip to content

Instantly share code, notes, and snippets.

@priithaamer
Created September 6, 2011 16:01

Revisions

  1. Priit Haamer revised this gist Sep 28, 2011. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion noir.rb
    Original file line number Diff line number Diff line change
    @@ -10,5 +10,8 @@
    doc.css('table.contentpaneopen:nth-child(2) p').each do |p|
    print = false if p.text =~ /Sinu NOIR/
    print = true if p.text =~ /PAKKUMINE/
    puts p.text.gsub(/[\s ]+/, ' ') if print
    if print
    p.search('br').each{ |br| br.replace(Nokogiri::XML::Text.new("\n", p.document)) }
    puts p.text
    end
    end
  2. Priit Haamer revised this gist Sep 7, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions noir.rb
    Original file line number Diff line number Diff line change
    @@ -10,5 +10,5 @@
    doc.css('table.contentpaneopen:nth-child(2) p').each do |p|
    print = false if p.text =~ /Sinu NOIR/
    print = true if p.text =~ /PAKKUMINE/
    puts p.text if print
    end
    puts p.text.gsub(/[\s ]+/, ' ') if print
    end
  3. Priit Haamer created this gist Sep 6, 2011.
    14 changes: 14 additions & 0 deletions noir.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/usr/bin/env ruby

    require 'rubygems'
    require 'nokogiri'
    require 'open-uri'

    print = false

    doc = Nokogiri::HTML(open("http://www.cafenoir.ee/noir/"))
    doc.css('table.contentpaneopen:nth-child(2) p').each do |p|
    print = false if p.text =~ /Sinu NOIR/
    print = true if p.text =~ /PAKKUMINE/
    puts p.text if print
    end