public
Description: Find some previously used domain names and check availability
Homepage:
Clone URL: git://github.com/remi/domain-finder.git
remi (author)
Fri Feb 06 13:03:28 -0800 2009
commit  164acdd8a744c98fd6f54cc2ccc684a7e2242f4e
tree    9dfe2d4c97d238525d92dd70eecd7f8ee65c1f28
parent  deb12117130b602f8f655a82e31b672d54be9bec
100644 114 lines (93 sloc) 3.4 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require 'optparse'
require 'simplecli'
 
class DomainFinder::Bin
  include SimpleCLI
 
  def usage *args
    puts <<doco
 
domain-finder == %{ domain availability utility }
 
Usage:
domain-finder -h/--help [Not Implemented Yet]
domain-finder -v/--version [Not Implemented Yet]
domain-finder command [options]
 
Examples:
domain-finder auction
 
Further help:
domain-finder commands # list all available commands
domain-finder help <COMMAND> # show help for COMMAND
domain-finder help # show this help message
 
doco
  end
 
  def available_help
    <<doco
Usage: #{ script_name } available domain.com[ domain2.com]
 
Summary:
Check the availability of domains (max 500)
doco
  end
  def available *domains
    available_domains = Domain.available? *domains
 
    unless available_domains.empty?
      puts "\nAvailable Domains:\n------------------"
      available_domains.sort.each do |domain|
        puts "- #{domain}"
      end
    else
      puts "No Domains Available"
    end
  end
 
  def auction_help
    <<doco
Usage: #{ script_name } auction
 
Options:
-d, --dates Set of dates to use in search
-k, --keywords Comma-delimited keywords for domain titles
-p, --pages Number of Google pages to gather domains from
-f, --file Name of a text file to save available domain names to
 
Examples:
#{ script_name } auction --dates 05-01-2008,06-10-2008..06.15.2008
#{ script_name } auction --keywords seo,blog --dates 06-01-2008..07-01-2008
#{ script_name } auction -f domains.txt --keywords cat,dog -p 2
 
Summary:
Display available auction domains
doco
  end
  def auction *args
    begin
      options = { :dates => [Date.today - 14], :pages => 1 }
      opts = OptionParser.new do |opts|
        opts.on('-d','--dates DATE'){ |d| options[:dates] = DateRange.parse(d) }
        opts.on('-k','--keywords WORDS'){ |w| options[:keywords] = w.split(',') }
        opts.on('-p','--pages PAGES'){ |p| options[:pages] = p.to_i }
        opts.on('-f','--file FILE'){ |f| options[:file] = f }
      end
      opts.parse! args
 
      query = %{"Auction Date" #{ options[:dates].join(' OR ') } site:whois.domaintools.com }
      query += options[:keywords].map { |k| "intitle:#{k}" }.join(' OR ') if options[:keywords]
 
      puts "Searching google ... [#{query}]"
      results = Google.search(query, :pages => options[:pages] )
 
      print "Getting domains ."
      auction_domains = results.inject([]) do |all,result|
        if result.cached
          print '.'
          all + DomainTools.auction_domains( open(result.cached) )
        else
          all # no google cache for this result, continue on to the next result
        end
      end
      print "\n"
      
      puts "Checking availability of #{ auction_domains.length } domains ..."
      available_domains = Domain.available? *auction_domains
      
      unless available_domains.empty?
        puts "\nAvailable Domains:\n------------------"
        available_domains.sort.each do |domain|
          puts "- #{domain}"
        end
        File.open(options[:file],'w'){|f| f << available_domains.sort.join("\n") } if options[:file]
      else
        puts "No Domains Available"
      end
    rescue => ex
      puts "Exception: #{ex.inspect}"
    end
  end
 
end