Для определения стоимости покупки домена вы можете использовать различные методы в зависимости от языка программирования или технологии, с которой вы работаете. Вот несколько примеров на разных языках:
-
Python с библиотекой запросов:
import requests def get_domain_cost(domain_name): url = f"https://api.domain.com/pricing?domain={domain_name}" response = requests.get(url) data = response.json() cost = data["price"] return cost # Example usage domain = "example.com" cost = get_domain_cost(domain) print(f"The cost of purchasing {domain} is: {cost}") -
Node.js с библиотекой axios:
const axios = require('axios'); async function getDomainCost(domainName) { const url = `https://api.domain.com/pricing?domain=${domainName}`; const response = await axios.get(url); const cost = response.data.price; return cost; } // Example usage const domain = 'example.com'; getDomainCost(domain) .then(cost => console.log(`The cost of purchasing ${domain} is: ${cost}`)) .catch(error => console.error(error)); -
PHP с cURL:
function getDomainCost($domainName) { $url = "https://api.domain.com/pricing?domain=" . urlencode($domainName); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); $cost = $data["price"]; return $cost; } // Example usage $domain = "example.com"; $cost = getDomainCost($domain); echo "The cost of purchasing $domain is: $cost";
Не забудьте заменить "https://api.domain.com/pricing"фактической конечной точкой API или службой ценообразования, которую вы собираетесь использовать для получения стоимости домена.