Чтобы получить стоимость регистрации доменного имени, вы можете использовать различные методы в зависимости от регистратора домена или API, с которым вы работаете. Вот несколько методов и примеры кода с использованием разных популярных регистраторов доменов:
-
GoDaddy API (Python):
import requests def get_domain_price(domain_name): url = "https://api.godaddy.com/v1/domains/pricing/{0}".format(domain_name) response = requests.get(url) data = response.json() return data['price'] # Example usage domain = "example.com" price = get_domain_price(domain) print("The registration price for {0} is {1}".format(domain, price)) -
API Namecheap (Python):
import requests def get_domain_price(domain_name): url = "https://api.namecheap.com/xml.response" params = { "ApiUser": "your_api_user", "ApiKey": "your_api_key", "UserName": "your_username", "Command": "namecheap.domains.getTldList", "ClientIp": "your_ip_address" } response = requests.get(url, params=params) # Parse the XML response and extract the price for the domain name # ... # Example usage domain = "example.com" price = get_domain_price(domain) print("The registration price for {0} is {1}".format(domain, price)) -
Поиск Whois (Python):
import whois def get_domain_price(domain_name): w = whois.whois(domain_name) # Extract the registration price from the whois data # ... # Example usage domain = "example.com" price = get_domain_price(domain) print("The registration price for {0} is {1}".format(domain, price))
Обратите внимание, что приведенные выше примеры кода являются лишь иллюстрациями и могут потребовать дополнительных изменений в зависимости от конкретного регистратора или API, который вы используете. Кроме того, доступность информации о ценах на домены через API или поиск Whois может варьироваться в зависимости от регистратора и его политики.