Skip to content

Instantly share code, notes, and snippets.

@bahamut45
Created October 1, 2014 15:12
Show Gist options
  • Save bahamut45/b256431483266edad27f to your computer and use it in GitHub Desktop.
Save bahamut45/b256431483266edad27f to your computer and use it in GitHub Desktop.
rtgi-rne
#!/usr/bin/ruby1.9.1
# encoding: utf-8
##########################################################################################
RTGI_URL = 'https://rtgi.giprecia.fr'
#########################################################################################
require 'yaml'
require 'mechanize'
require 'json'
config_file = ARGV[0] or abort("Pas de fichier de configuration donné en argument")
config = YAML.load_file config_file
rne_name = []
a = Mechanize.new
a.get RTGI_URL do |login_page|
main_page = login_page.form_with :id => 'fauthent' do |form|
form.elogin = config['login']
form.epasswd = config['password']
end.click_button
bigmap_page = main_page.link_with(text: 'BigMap').click
bigmap_page.search('//table//tr').drop(1).each do |tr|
rne = tr.search('td[1]').text
name = tr.search('td[2]').text
# puts "#{rne},#{name}"
rne_name << {'rne' => rne, 'name' => name}
end
end
puts rne_name.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment