Skip to content

Instantly share code, notes, and snippets.

@saberma
Created June 28, 2010 13:31
Show Gist options
  • Save saberma/455835 to your computer and use it in GitHub Desktop.
Save saberma/455835 to your computer and use it in GitHub Desktop.
批量查询域名
#!/usr/bin/env ruby
# sudo apt-get install libnotify-bin
# gem install bulkdom
# gem install notify
require 'bulkdom'
require 'notify'
letters = File.read('letters').chomp
size = letters.size
@dl = Bulkdom::DomainList.new
@dl.tlds = [".com"]
begin
File.open('letters', 'w') {|f| f.write(letters)}
domains_to_check = []
print '.'
begin
domains_to_check << letters
letters = letters.next
end until domains_to_check.size >= 26
#start check
print '.'
@dl.list = domains_to_check
@dl.process
#finish check
print '.'
#Let it process for a while... @dl.processed will be set to true when done!
result = @dl.return_available(".com")
unless result.empty?
puts result
Notify.notify "domain valid!", result.join("\n")
File.open('domains.log', 'a') do |f|
#f.write "#{Time.now}\n"
f.write result.join("\n")
end
end
end until letters.size > size
#http://www.heartinternet.co.uk/domain-names/domain-search.html?multi=1&domain=sina.com%0D%0Atwitter.com
base_url = 'http://www.heartinternet.co.uk/domain-names/domain-search.html?multi=1&domain='
scope = (:a..:z).to_a - [:f, :j, :l, :r, :w, :y, :z]
scope.each do |one|
domains = []
scope.each do |two|
#domains << "shop#{one}#{two}.com"
domains << "shop#{one}#{two}.com"
end
url = "#{base_url}#{domains.join('%0D%0A')}"
system "chromium-browser '#{url}'"
sleep 60
end
# -*- encoding : utf-8 -*-
require 'ap'
@table = {}
open(File.dirname(__FILE__) + '/data/Mandarin.dat') do |file|
while line = file.gets
key, value = line.split(' ', 2)
value = value.gsub(/\d+/, '').chomp
if value.size <= 3 and value.size > 1 and !value.index(' ') and value.size == 3
if !value.start_with?('Z') and !value.start_with?('C') and !value.start_with?('S')
if !value.end_with?('AN') and !value.end_with?('ANG') and !value.end_with?('EN') and !value.end_with?('ENG')
@table[value] ||= []
@table[value] << key
end
end
end
end
end
p @table.size
ap @table.keys.sort {|a,b| a.size <=> b.size}.join(' or ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment