Skip to content
TheChatArchiveThe Chat Archive
Coherecommand-a-03-2025· CohereHugging Face LMArena Human Preference 140K

I'd to create a script to find all domain names that include a specific term. How can I…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219-thinking-32k’s answer.
  1. User

    I'd to create a script to find all domain names that include a specific term. How can I do that?

  2. Cohere Assistant

    Creating a script to find all domain names that include a specific term involves several steps. You can use a combination of WHOIS databases, domain registrars' APIs, or web scraping techniques. Below is a Python-based approach using the whois library and public APIs to search for domain names containing a specific term.

    Prerequisites

    1. Install Required Libraries:

      pip install python-whois
      pip install requests
      
    2. API Keys: Some domain registrars or services may require API keys for bulk lookups. For this example, we'll use a simple approach without API keys.

    Script to Find Domain Names Containing a Specific Term

    import whois
    import requests
    from urllib.parse import quote
    
    def find_domains_with_term(term, tld='com', limit=10):
        """
        Find domain names containing a specific term.
    
        :param term: The term to search for in domain names.
        :param tld: The top-level domain to search within (e.g., 'com', 'net', 'org').
        :param limit: The maximum number of results to return.
        :return: A list of domain names containing the term.
        """
        found_domains = []
        base_url = f"https://api.domainsdb.info/v1/domains/search?domain={quote(term)}&zone={tld}"
    
        try:
            response = requests.get(base_url)
            response.raise_for_status()
            data = response.json()
    
            for domain_info in data['domains']:
                domain_name = domain_info['domain']
                if term in domain_name:
                    found_domains.append(domain_name)
                    if len(found_domains) >= limit:
                        break
    
            return found_domains
    
        except requests.exceptions.RequestException as e:
            print(f"Error fetching domain data: {e}")
            return []
    
    def check_domain_availability(domain):
        """
        Check if a domain is available using WHOIS.
    
        :param domain: The domain name to check.
        :return: True if available, False if registered.
        """
        try:
            w = whois.whois(domain)
            return w.expiration_date is None
        except Exception as e:
            print(f"Error checking domain {domain}: {e}")
            return False
    
    if __name__ == "__main__":
        search_term = "example"  # Replace with your desired term
        tld_to_search = "com"    # Replace with the desired TLD
        max_results = 10         # Maximum number of results to return
    
        domains = find_domains_with_term(search_term, tld_to_search, max_results)
    
        print(f"Domains containing '{search_term}' in the '{tld_to_search}' TLD:")
        for domain in domains:
            availability = check_domain_availability(domain)
            status = "Available" if availability else "Registered"
            print(f"{domain}: {status}")
    

    Explanation

    1. find_domains_with_term Function:

      • Uses the domainsdb.info API to search for domains containing the specified term within a given TLD.
      • Filters the results to include only domains that contain the term.
    2. check_domain_availability Function:

      • Uses the python-whois library to check if a domain is available or already registered.
    3. Main Script:

      • Calls the functions to find and display domains containing the specified term, along with their availability status.

    Alternative Approaches

    • Web Scraping: Scrape domain registrars' websites (e.g., GoDaddy, Namecheap) for domain availability.
    • Brute Force: Generate permutations of the term and check their availability using WHOIS.

    Notes

    • Rate Limiting: Be mindful of API rate limits when making bulk requests.
    • Accuracy: WHOIS data may not always be up-to-date or accurate.
    • Legal Compliance: Ensure your script complies with the terms of service of the APIs or services you use.

    This script provides a basic framework. Depending on your needs, you may want to expand it with error handling, logging, or additional features.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.