Spaces:
Runtime error
Runtime error
File size: 948 Bytes
fffd163 |
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 |
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.",
)
|