以下是一個示例,使用Python的requests和BeautifulSoup庫來檢查域名是否可用:

import requests
from bs4 import BeautifulSoup

def check_domain(domain):
    url = f"https://www.namecheap.com/domains/registration/results/?domain={domain}"
    response = requests.get(url)
    soup = BeautifulSoup(response.content, "html.parser")
    result = soup.find("div", {"class": "results"}).text.strip()
    if result == "Domain name is available":
        return True
    else:
        return False

# Example usage
print(check_domain("example.com")) # Output: False
print(check_domain("example123456.com")) # Output: True

這個示例使用Namecheap的域名查詢API。我們可以將要查詢的域名傳遞給URL,然後使用requests庫向該URL發送HTTP請求。網頁的內容被解析為BeautifulSoup對象,我們可以使用它來查找網頁上顯示的域名狀態。如果域名可用,則返回True,否則返回False

python 查詢域名是否可以注冊 不用whois的示例

原文地址: https://www.cveoy.top/t/topic/gkZQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录