Class: DomainFinder::Bin
- Inherits:
-
Object
- Object
- DomainFinder::Bin
- Includes:
- SimpleCLI
- Defined in:
- lib/domain-finder/bin.rb
Instance Method Summary collapse
- #auction(*args) ⇒ Object
- #auction_help ⇒ Object
- #available(*domains) ⇒ Object
- #available_help ⇒ Object
- #usage(*args) ⇒ Object
Instance Method Details
#auction(*args) ⇒ Object
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 |
# File 'lib/domain-finder/bin.rb', line 68 def auction *args begin = { :dates => [Date.today - 14], :pages => 1 } opts = OptionParser.new do |opts| opts.on('-d','--dates DATE'){ |d| [:dates] = DateRange.parse(d) } opts.on('-k','--keywords WORDS'){ |w| [:keywords] = w.split(',') } opts.on('-p','--pages PAGES'){ |p| [:pages] = p.to_i } opts.on('-f','--file FILE'){ |f| [:file] = f } end opts.parse! args query = %{"Auction Date" #{ [:dates].join(' OR ') } site:whois.domaintools.com } query += [:keywords].map { |k| "intitle:#{k}" }.join(' OR ') if [:keywords] puts "Searching google ... [#{query}]" results = Google.search(query, :pages => [: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([:file],'w'){|f| f << available_domains.sort.join("\n") } if [:file] else puts "No Domains Available" end rescue => ex puts "Exception: #{ex.inspect}" end end |
#auction_help ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/domain-finder/bin.rb', line 49 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 |
#available(*domains) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/domain-finder/bin.rb', line 36 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 |
#available_help ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/domain-finder/bin.rb', line 28 def available_help <<doco Usage: #{ script_name } available domain.com[ domain2.com] Summary: Check the availability of domains (max 500) doco end |
#usage(*args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/domain-finder/bin.rb', line 7 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 |