Josep Pon Farreny
chore: Multiple fixes and whois tool
fffd163
raw
history blame
948 Bytes
import json
import gradio as gr
import whois
from tdagent.utils.json_utils import TDAgentJsonEncoder
def query_whois(url: str) -> str:
"""Query a WHOIS database to gather information about a url or domain.
WHOIS information includes: domain names, IP address blocks and autonomous
systems, but it is also used for a wider range of other information.
Args:
url: URL to query for WHOIS information.
Returns:
A JSON formatted string with the gathered information
"""
try:
whois_result = whois.whois(url)
except whois.parser.PywhoisError as err:
return json.dumps({"error": str(err)})
return json.dumps(whois_result, cls=TDAgentJsonEncoder)
gr_query_whois = gr.Interface(
fn=query_whois,
inputs=["text"],
outputs="text",
title="Get WHOIS information for a given URL.",
description="Query a WHOIS database to gather information about a url or domain.",
)