Skip to content

Commit

Permalink
Order output
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtmtmtm committed Jun 26, 2015
1 parent cb7b3fb commit 9db9f05
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scraper.rb
Expand Up @@ -14,16 +14,18 @@ def json_from(url)
JSON.parse(open(url).read, symbolize_names: true)
end

PAGE = 'http://www.assnat.cm/gestionLoisLegislatures/sujetsForum.php?filterscount=0&groupscount=0&pagenum=0&pagesize=200&recordstartindex=0&recordendindex=0&affichageDeputes=true&legislature=%s+Legislative'

PAGE_EN = 'http://www.assnat.cm/gestionLoisLegislatures/gestionDeputesEN.php?filterscount=0&groupscount=0&pagenum=0&pagesize=200&recordstartindex=0&recordendindex=0&affichageDeputes=true&legislature=%s+Legislative'
PAGE_FR = 'http://www.assnat.cm/gestionLoisLegislatures/sujetsForum.php?filterscount=0&groupscount=0&pagenum=0&pagesize=200&recordstartindex=0&recordendindex=0&affichageDeputes=true&legislature=%s+Legislative'

terms = %w(1st 2nd 3rd 4th 5th 6th 7th 8th 9th)

terms.each do |term|
url = PAGE % term
puts "Fetching #{url}"
url = PAGE_EN % term
puts "Fetching #{term} Assembly"
json = json_from(url).first
next if json[:TotalRows].to_i.zero?
json[:Rows].each do |row|
json[:Rows].sort_by { |r| r[:ID_Depute] }.each do |row|
data = {
id: row[:ID_Depute],
name: row[:nomPrenom],
Expand Down

0 comments on commit 9db9f05

Please sign in to comment.