Created
April 17, 2021 14:54
-
-
Save elseym/0905e97f75f8a03c82a62f8b0f13d10e to your computer and use it in GitHub Desktop.
Porkbun Domain Price List
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
#! /usr/bin/env nix-shell | |
#! nix-shell -i bash -p curl jq pup utillinux | |
declare -x PB_YEARS=${PB_YEARS:-5} | |
declare -x PB_LIMIT=${PB_LIMIT:-23} | |
echo "Loading the $PB_LIMIT cheapest (over $PB_YEARS years) TLDs from porkbun.com..." | |
echo; ( | |
cat .pbcache.json 2>/dev/null || | |
curl -ksSLo- 'https://porkbun.com/products/domains' | |
) \ | |
| pup '.domainsPricingAllExtensionsItem .row json{}' \ | |
| jq -r ' | |
def round: . * 100 | ceil / 100; | |
def parse: . | gsub(","; "") | tonumber | round; | |
.[]|={ | |
url: .children[0].children[ 0].href, | |
tld: .children[0].children[ 0].text | ltrimstr("."), | |
reg: .children[1].children[-1].text | parse | round, | |
ren: .children[2].children[-1].text | parse | round, | |
xfr: .children[3].children[-1].text | parse | round, | |
} | | |
.[]|=.+{ | |
sum: (.reg + ((env.PB_YEARS | tonumber) - 1) * .ren) | round | |
} | | |
sort_by(.sum)[0:(env.PB_LIMIT | tonumber)] | |
' \ | |
| jq -r '.[] | map(.) | @tsv' \ | |
| column -t -O2,6,3,4,5 -R6,3,4,5 -H1 \ | |
-N"URL","TLD","Register","Renew","Transfer","${PB_YEARS} years" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment