-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain_appraisal
More file actions
executable file
·78 lines (59 loc) · 2.09 KB
/
domain_appraisal
File metadata and controls
executable file
·78 lines (59 loc) · 2.09 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
#!/bin/python3
#----------------------------------------------------------
#
# Batch Appraise Domain Names
# (uses humbleworth.com API endpoint)
#
# RICK PFAHL <pfahlr@gmail.com>
# 16 MAY 2024
#
#---------------------------------------------------------
#
# usage: domain_appraisal [-h] --outfile OUTFILE [--tld TLD] input_file
#
import csv
import json
import requests
import argparse
import time
def read_csv(file_path):
with open(file_path, newline='') as csvfile:
reader = csv.DictReader(csvfile)y
rows = [row for row in reader]
return rows
def get_domain_names(rows, tld):
domain_names = [f"{row['Domain']}" for row in rows]
return domain_names
#
#API Documentation https://humbleworth.com/page/about/api
#
def make_api_call(domains):
url = "https://valuation.humbleworth.com/api/valuation"
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers, json={"domains":domains})
if response.status_code == 200:
time.sleep(1)
print("response:200, OK!... got 20 rows"+domains)
return response.json()['valuations']
else:
response.raise_for_status()
def main(input_file, output_file_base, tld):
rows = read_csv(input_file)
domain_names = get_domain_names(rows, tld)
all_valuations = []
for i in range(0, len(domain_names), 20):
batch = domain_names[i:i+20]
valuations = make_api_call(batch)
all_valuations.extend(valuations)
output_file = f"{output_file_base}.json"
with open(output_file, 'w') as outfile:
json.dump(all_valuations, outfile, indent=4)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process CSV and get domain valuations.")
parser.add_argument("input_file", help="Path to the input CSV file.")
parser.add_argument("--outfile", "-o", required=True, help="Base name for the output file.")
parser.add_argument("--tld", "-d", default="com", help="Top-level domain to append.")
args = parser.parse_args()
main(args.input_file, args.outfile, args.tld)