import gradio as gr import socket from urllib.parse import urlparse def domain_to_ip(website): try: # Ensure input is clean (remove http/https if present) parsed_url = urlparse(website) domain = parsed_url.netloc if parsed_url.netloc else parsed_url.path if not domain: return "āŒ Invalid website input." ip_address = socket.gethostbyname(domain) return f"🌐 Domain: {domain}\nšŸ“ IP Address: {ip_address}" except socket.gaierror: return "āŒ Could not resolve domain. Please check the website name." except Exception as e: return f"āŒ Error: {str(e)}" iface = gr.Interface( fn=domain_to_ip, inputs=gr.Textbox(label="Enter Website URL or Domain", placeholder="e.g. google.com or https://example.com"), outputs=gr.Markdown(label="IP Address"), title="Website to IP Converter", description="Enter a website name or URL (with or without http/https) to get its IP address." ) if __name__ == "__main__": iface.launch()