<!DOCTYPE html>
<html>
<head>
<title>企業情報検索</title>
</head>
<body>
<h1>企業情報検索</h1>
<label for="urlInput">URL:</label>
<input type="text" id="urlInput">
<button onclick="getCompanyInfo()">検索</button>
<div id="result"></div>
<script>
function getCompanyInfo() {
var url = document.getElementById("urlInput").value;
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.example.com/company-info?url=" + encodeURIComponent(url), true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
displayResult(response);
}
};
xhr.send();
}
function displayResult(response) {
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = "";
if (response.success) {
resultDiv.innerHTML = "<h2>企業情報</h2>" +
"<p>企業名: " + response.companyName + "</p>" +
"<p>本社所在地: " + response.headquarters + "</p>" +
"<p>代表番号: " + response.contactNumber + "</p>" +
"<p>メールアドレス: " + response.email + "</p>";
} else {
resultDiv.innerHTML = "<p>企業情報が取得できませんでした。</p>";
}
}
</script>
</body>
</html>