Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit b59f413b10e7a135393c8ca568ae88679e5ecac9 Alexandre Girard committed Jan 5, 2009
Showing with 39 additions and 0 deletions.
  1. +39 −0 sceance.rb
39 sceance.rb
@@ -0,0 +1,39 @@
+require 'rubygems'
+require 'nokogiri'
+require 'open-uri'
+
+deputies = Hash.new
+
+def deputy_name(deputy_id)
+ fiche = "http://www.assemblee-nationale.fr/13/tribun/fiches_id/#{deputy_id}.asp"
+ doc = Nokogiri::HTML(open(fiche))
+ return doc.xpath('//h1[@class="titre"]').first.content
+end
+
+def deputy_seat(deputy_id)
+ fiche = "http://www.assemblee-nationale.fr/13/tribun/fiches_id/#{deputy_id}.asp"
+ doc = Nokogiri::HTML(open(fiche))
+ return doc.xpath('//div[@id="phemi"]/p').first.content.slice(/: (\d+)/, 1)
+end
+
+def parse_sceance(deputies, sceance_url)
+ doc = Nokogiri::HTML(open(sceance_url))
+
+ doc.xpath('//p/b/a[@target="_top"]').each do |link|
+ deputy = link['href'].slice(/(\d+).asp/, 1)
+
+ if deputies.key?(deputy)
+ deputies[deputy] = deputies[deputy].to_i + 1
+ else
+ deputies[deputy] = 1
+ end
+ end
+end
+
+parse_sceance(deputies, "http://www.assemblee-nationale.fr/13/cri/2008-2009/20090090.asp")
+
+deputies.sort{|a,b| b[1]<=>a[1]}.each { |elem|
+ puts "#{elem[1]}, #{deputy_name(elem[0])} - Place: #{deputy_seat(elem[0])}"
+}
+
+

0 comments on commit b59f413

Please sign in to comment.