Created
January 11, 2017 03:22
-
-
Save dylanj/1d1c8935df762d1d15d87a26fa35367c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prints all? domain+tld combos which are available. | |
require 'nokogiri' | |
require "net/http" | |
require "uri" | |
def tldsearch(domain) | |
args = { d: domain, r: 'ALL', freedom: 0, onlydom: 0, option: 0 } | |
endpoint = "https://www.inwx.com/de/domain/check2ajax" | |
req_start = Time.now | |
resp = Net::HTTP.post_form( URI.parse(endpoint), args) | |
# resp = HTTParty.post(domain, body: args) | |
req_total = Time.now - req_start | |
body = resp.body | |
n = Nokogiri::HTML(body) | |
parse_start = Time.now | |
rows = n.css('.inwx-check-row.free') | |
available = rows.count | |
taken = n.css('.inwx-check-row.taken').count | |
rows = rows.map do |r| | |
price_original = r.children.css('[data-price]').first.children.text | |
price = price_original.gsub(/^W/,'').to_f | |
domain = r.attributes["id"].value.gsub(/domain_container_/, "") | |
country = r.children.first.children.last.text | |
{ | |
domain: domain, | |
country: country, | |
price: price, | |
price_original: price_original | |
} | |
end; 0 | |
parse_total = Time.now - parse_start | |
puts "Found: #{(taken + available)} (#{available} available) domains" | |
puts "Request took #{req_total}seconds" | |
puts "Parsing took #{parse_total}seconds" | |
rows.sort { |x,y| x[:price] <=> y[:price] }.each do |x| | |
puts "#{x[:price_original]} - #{x[:domain]} - #{x[:country]}" | |
end; 0 | |
end | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment