ruby来枚举csdn未注册的用户名

简介:

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

相关文章
|
2月前
|
Ruby
|
2月前
|
Ruby
|
1月前
|
数据采集 Web App开发 数据处理
Ruby网络爬虫教程:从入门到精通下载图片
Ruby网络爬虫教程:从入门到精通下载图片
|
2月前
|
JSON 数据格式 Ruby
|
2月前
|
JSON Ubuntu Linux
|
2月前
|
存储 JSON 数据格式
|
2月前
|
安全 Ruby
|
2月前
|
调度 Ruby
|
2月前
|
人工智能 BI 计算机视觉