Чтобы выполнить проверку регистрации домена веб-сайта, вы можете использовать различные методы в зависимости от ваших требований и используемого языка программирования. Вот несколько методов с примерами кода с использованием популярных языков программирования:
-
Использование WHOIS API:
-
Пример Python с использованием библиотеки
python-whois:import whois def check_domain_registration(domain): try: w = whois.whois(domain) if w.status: print("Domain is registered.") else: print("Domain is not registered.") except whois.parser.PywhoisError: print("Domain is not registered.") check_domain_registration("example.com")
-
-
Отправка HTTP-запроса в домен:
-
Пример Python с использованием библиотеки
requests:import requests def check_domain_registration(domain): try: response = requests.get(f"http://{domain}") if response.status_code == 200: print("Domain is registered.") else: print("Domain is not registered.") except requests.exceptions.RequestException: print("Domain is not registered.") check_domain_registration("example.com")
-
-
Использование поиска DNS:
-
Пример JavaScript с использованием модуля
dns(Node.js):const dns = require('dns'); function checkDomainRegistration(domain) { dns.resolve(domain, (error) => { if (error && error.code === 'ENOTFOUND') { console.log('Domain is not registered.'); } else { console.log('Domain is registered.'); } }); } checkDomainRegistration('example.com');
-