Auto. Domain check u. Registrierung Script?

1 Antwort

import requests
import json

# Set the list of domains to check
domains = ["example.com", "example.net", "example.org"]

# Set the inwx API key
inwx_api_key = "YOUR_API_KEY"

# Define the function to check if a domain is free
def is_domain_free(domain):

    # Make a request to the inwx API
    response = requests.get("https://api.inwx.de/v1/domains/check", headers={"Authorization": "Bearer {}".format(inwx_api_key), "Content-Type": "application/json"})

    # Check the response status code
    if response.status_code == 200:

        # The domain is free
        return True

    # The domain is not free
    return False

# Loop through the list of domains
for domain in domains:

    # Check if the domain is free
    if is_domain_free(domain):

        # The domain is free, so register it
        print("Domain {} is free, registering it".format(domain))

        # Make a request to the inwx API to register the domain
        response = requests.post("https://api.inwx.de/v1/domains/register", headers={"Authorization": "Bearer {}".format(inwx_api_key), "Content-Type": "application/json"}, data=json.dumps({"domain": domain}))

        # Check the response status code
        if response.status_code == 201:

            # The domain was successfully registered
            print("Domain {} was successfully registered".format(domain))

        else:

            # The domain could not be registered
            print("Error registering domain {}: {}".format(domain, response.status_code))

    else:

        # The domain is not free, so skip it
        print("Domain {} is not free, skipping it".format(domain))
Woher ich das weiß:Recherche