require 'kconv'
require 'net/http'
Net::HTTP.version_1_2
h = Hash.new{|hash, key| hash[key] = {} }
http=Net::HTTP.new('profile.yahoo.co.jp', 80)
name=''
ARGF.each do |no|
req=Net::HTTP::Get.new('/consolidate/' << no.chomp!)
response=http.request(req)
flg=0
k=''
response.body.each do |line|
if /
(.*?)=~line then
name=Kconv.tosjis($1)
end
if /(.*?)=~line then
k=Kconv.tosjis($1)
flg=0
end
if / | (.*?)=~line && flg==0 then
h[name][k]=Kconv.tosjis($1.gsub(/,/,'')).gsub(/•S–œ/,'0000000').gsub(/‰~/,'')
flg=1
end
end
req=Net::HTTP::Get.new('/fundamental/' << no)
response=http.request(req)
response.body.each do |line|
if / | (.*?)<.*?>(.*?)=~line then
k=Kconv.tosjis($1+$2)
flg=0
end
if / | (.*?)=~line && flg==0 then
h[name][k]=Kconv.tosjis($1.gsub(/,/,'')).gsub(/l/,'')
flg=1
end
if / | (.*?)=~line then
k=Kconv.tosjis($1)
flg=0
end
if / | (.*?)=~line && flg==0 then
h[name][k]=Kconv.tosjis($1.gsub(/,/,'')).gsub(/ç/,'000').gsub(/‰~/,'')
flg=1
end
end
end
print 'name,'
h[name].keys.each do |key2|
print key2 + ','
end
puts
h.keys.each do |key1|
print key1 + ','
h[key1].keys.each do |key2|
print h[key1][key2] + ','
end
puts
end
| |