Created
March 6, 2014 05:23
-
-
Save ckazu/9383096 to your computer and use it in GitHub Desktop.
HRF の複合グラフを生成する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'nokogiri' | |
require 'open-uri' | |
service_name = 'kakin_daily' | |
section_name = 'count_uu_Android' | |
doc = Nokogiri::HTML(open 'https://hostname/add_complex') | |
graph_ids = doc.css('form select[name=path-add] option'). | |
select {|graph| graph.content.match "/#{service_name}/#{section_name}/" }. | |
map {|graph| { 'path-data' => graph['value'] } } | |
options = { | |
stack: 1, | |
sort: 1, | |
service_name: service_name, | |
section_name: section_name, | |
graph_name: 'all' | |
} # don't merge graph_ids. duprecated key name | |
a = options.map {|key, value| %Q|-d "#{key}=#{value}"| }.join(' ') | |
b = graph_ids.map { |graph| %Q|-d "#{graph.keys.pop}=#{graph.values.pop}"| }.join(' ') | |
query = "#{a} #{b}" | |
result = `curl -X POST https://hostname/add_complex #{query}` | |
p JSON.parse result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment