Created
December 8, 2020 11:46
-
-
Save Cgboal/13895356db66269897ca6bae290cbbbd to your computer and use it in GitHub Desktop.
Pull reverse whois info from reverse-whois.whoisxmlapi.com
This file contains hidden or 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
#!/usr/bin/bb | |
(require '[babashka.curl :as curl]) | |
(require '[cheshire.core :as json]) | |
(require '[clojure.string :as s]) | |
(def my-api-key "PUT_YOUR_API_KEY_HERE") | |
(defn make-request-body [api-key query] | |
{:apiKey api-key | |
:searchType "current" | |
:mode "purchase" | |
:punycode true | |
:basicSearchTerms {:include [query] | |
:exclude []}}) | |
(defn fetch-results [api-key query] | |
(curl/post "https://reverse-whois.whoisxmlapi.com/api/v2" {:headers {"Accept" "application/json"} | |
:body (json/generate-string (make-request-body api-key query))})) | |
(defn extract-domains [resp] | |
(-> resp | |
(:body) | |
(json/parse-string true) | |
(:domainsList) | |
(->> (s/join "\n")))) | |
(defn reverse-whois [api-key query] | |
(-> (fetch-results api-key query) | |
(extract-domains))) | |
(println (reverse-whois my-api-key (first *command-line-args*))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment