require 'open-uri'
$NAME_CHARS= (?a..?z).to_a+(?0..?9).to_a
def is_name_used(name)
str=open('http://passport.csdn.net/UserExist.aspx?UserName='+name)
str=str.read
#str=str.encode('GBK','utf-8')
return true if str[/Red/]
end
def enum_names(len=2)
return if len<2
f=File.open('d:/work/a.txt',"w+")
strpack="A"*len
i,v=0,""
$NAME_CHARS.permutation(len) do |x|
v=x.pack(strpack)
break if v[/^[/d]+/]
#p i+=1
f.puts "#{i+=1} : #{v}"
f.puts "#{v} is not use!" unless is_name_used(v)
end
rescue =>ex
p "err : #{ex.to_s}(#{v})"
ensure
f.close if f
end
时间: 2024-10-27 15:22:06