meeb / whoisit

A Python library to RDAP WHOIS-like services for internet resources such as ASNs, IPs, CIDRs and domains
BSD 3-Clause "New" or "Revised" License
78 stars 20 forks source link

Follow related links #26

Closed dumkydewilde closed 5 months ago

dumkydewilde commented 6 months ago

Many RDAP requests are returned with a related link containing more information about the domain. For example, the .com domain is handled by Verisign, but Verisign might return a related link to the registrar for more information. For example, looking up amazon.com will yield a link to the registrar (MarkMonitor) with more information.

I feel like this might be a nice addition for convenience, maybe by adding an optional parameter for following relations. I currently have a super simple implementation as follows, which definitely has room for improvement. If you are interested or have additional thoughts, I am happy to create a PR.

tld_domain = "amazon.com"
result = whoisit.domain(tld_domain, raw=True)

for link in result.get("links", []):
    if link["rel"] in ["related", "registration"]:
        res = requests.get(link.get("href", ""))
        result = res.json() # overwrite result if a related link was followed

parsed_result = whoisit.parse(whoisit._bootstrap, "domain", tld_domain, result)
meeb commented 6 months ago

That sounds a sensible suggestion. Thanks for the example!

meeb commented 5 months ago

This is bundled into the latest release and is enabled by default, you won't need your hack any longer. Thanks again for the suggestion.

dumkydewilde commented 5 months ago

This is amazing! Thanks for fixing 👌