Skip to content

Instantly share code, notes, and snippets.

@takuya
Created February 25, 2014 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuya/9216067 to your computer and use it in GitHub Desktop.
Save takuya/9216067 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# coding: utf-8
require 'mechanize'
require 'kconv'
def regist( mail )
Thread.new{
m = Mechanize.new
m.get 'https://www2.kepco.co.jp/kenshinnet/N08DA01.do'
m.page.forms[0].field_with( :name=> /email/).value = mail
m.page.forms[0].field_with( :name=> /emailKaknin/).value = mail
m.page.forms[0].checkbox(:name=>/kiyakuCheck/)
m.page.forms[0].checkbox(:name=>/kiyakuCheck/).check
m.page.forms[0].action
m.page.forms[0].action = "./N08DA08.do"
m.page.forms[0].submit
m.page.forms[0].action = "./N08DB07.do"
m.page.forms[0].submit
m.page.body.toutf8
print [mail, m.page.search("#contentsWrap div.recNumBox span").text.strip]
}
end
def gen_adress (delim=".",name="takuya1st")
name.size.times.map{|len|
(1...name.size).to_a.combination(len).to_a.map{|e|
str=name;
e.each_with_index{|pos,idx|
str= str.clone.insert(pos+idx,delim)
};
str
}
};
end
def regist_all
name = "takuya"
(1..1).map{|i| gen_adress("."*i, name) }.
flatten.sort.uniq.map{|e|
mail= "#{e}@example.com"
regist(mail)
}.each{|t| t.join}
end
regist_all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment