264 lines
8.9 KiB
HTML
264 lines
8.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Unbots - IP Data API</title>
|
|
<style>
|
|
body,
|
|
html {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
h1 {
|
|
color: #333;
|
|
border-bottom: 1px solid #eee;
|
|
padding-bottom: 10px;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 15px;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
font-weight: bold;
|
|
}
|
|
input[type="text"] {
|
|
width: 100%;
|
|
padding: 8px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
box-sizing: border-box;
|
|
}
|
|
button {
|
|
background-color: #4caf50;
|
|
color: white;
|
|
padding: 10px 15px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
button:hover {
|
|
background-color: #45a049;
|
|
}
|
|
#result {
|
|
margin-top: 20px;
|
|
padding: 15px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
background-color: #f9f9f9;
|
|
white-space: pre-wrap;
|
|
}
|
|
.highlight {
|
|
background-color: #f0f7ff;
|
|
padding: 10px;
|
|
border-left: 3px solid #0078d7;
|
|
margin-bottom: 15px;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin-top: 10px;
|
|
}
|
|
th,
|
|
td {
|
|
text-align: left;
|
|
padding: 8px;
|
|
border-bottom: 1px solid #ddd;
|
|
}
|
|
th {
|
|
background-color: #f2f2f2;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Unbots - IP Data API</h1>
|
|
<div class="form-group">
|
|
<label for="ip-input">Enter an IP address or domain:</label>
|
|
<input
|
|
type="text"
|
|
id="ip-input"
|
|
placeholder="e.g. 8.8.8.8 or example.com"
|
|
/>
|
|
</div>
|
|
<button onclick="lookupIP()">Lookup IP</button>
|
|
<div id="formatted-result" style="display: none">
|
|
<h3>IP Data</h3>
|
|
<table id="ip-data-table"></table>
|
|
<div class="highlight">
|
|
<h3>Hostname Information</h3>
|
|
<div id="hostname-data"></div>
|
|
</div>
|
|
</div>
|
|
<div id="result"></div>
|
|
<p>
|
|
<a id="api-link" href="https://ip.unbots.ru/">https://ip.unbots.ru/</a>
|
|
</p>
|
|
<p><a href="https://ip.unbots.ru/my">https://ip.unbots.ru/my</a></p>
|
|
|
|
<script>
|
|
function lookupIP() {
|
|
const ipInput = document.getElementById("ip-input").value.trim();
|
|
const resultDiv = document.getElementById("result");
|
|
const formattedResult = document.getElementById("formatted-result");
|
|
const hostnameData = document.getElementById("hostname-data");
|
|
const ipDataTable = document.getElementById("ip-data-table");
|
|
const apiLink = document.getElementById("api-link");
|
|
|
|
if (!ipInput) {
|
|
resultDiv.textContent = "Please enter an IP address";
|
|
formattedResult.style.display = "none";
|
|
return;
|
|
}
|
|
|
|
apiLink.textContent = `https://ip.unbots.ru/${ipInput}`;
|
|
apiLink.href = `https://ip.unbots.ru/${ipInput}`;
|
|
|
|
resultDiv.textContent = "Loading...";
|
|
formattedResult.style.display = "none";
|
|
|
|
fetch(`/${ipInput}`)
|
|
.then((response) => {
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
}
|
|
return response.json();
|
|
})
|
|
.then((data) => {
|
|
resultDiv.textContent = JSON.stringify(data, null, 2);
|
|
|
|
// Clear previous data
|
|
hostnameData.innerHTML = "";
|
|
ipDataTable.innerHTML = "";
|
|
|
|
// Format hostname information
|
|
if (data.hostname) {
|
|
hostnameData.innerHTML = `<p><strong>IP:</strong> ${data.ip}</p>
|
|
<p><strong>Hostname:</strong> ${data.hostname}</p>`;
|
|
} else {
|
|
hostnameData.innerHTML = `<p><strong>IP:</strong> ${data.ip}</p>
|
|
<p><strong>Hostname:</strong> <em>No hostname found</em></p>`;
|
|
}
|
|
|
|
// Format IP data table
|
|
let tableHTML = `<tr>
|
|
<th>Property</th>
|
|
<th>Value</th>
|
|
</tr>`;
|
|
|
|
if (data.asn)
|
|
tableHTML += `<tr><td>ASN</td><td>${data.asn}</td></tr>`;
|
|
if (data.as_name)
|
|
tableHTML += `<tr><td>AS Name</td><td>${data.as_name}</td></tr>`;
|
|
if (data.country_code)
|
|
tableHTML += `<tr><td>Country Code</td><td>${data.country_code}</td></tr>`;
|
|
if (data.country)
|
|
tableHTML += `<tr><td>Country</td><td>${data.country}</td></tr>`;
|
|
if (data.region)
|
|
tableHTML += `<tr><td>Region</td><td>${data.region}</td></tr>`;
|
|
if (data.city)
|
|
tableHTML += `<tr><td>City</td><td>${data.city}</td></tr>`;
|
|
if (data.latitude)
|
|
tableHTML += `<tr><td>Latitude</td><td>${data.latitude}</td></tr>`;
|
|
if (data.longitude)
|
|
tableHTML += `<tr><td>Longitude</td><td>${data.longitude}</td></tr>`;
|
|
if (data.zip_code)
|
|
tableHTML += `<tr><td>ZIP Code</td><td>${data.zip_code}</td></tr>`;
|
|
if (data.time_zone)
|
|
tableHTML += `<tr><td>Time Zone</td><td>${data.time_zone}</td></tr>`;
|
|
|
|
ipDataTable.innerHTML = tableHTML;
|
|
|
|
// Show formatted result
|
|
formattedResult.style.display = "block";
|
|
})
|
|
.catch((error) => {
|
|
resultDiv.textContent = `Error: ${error.message}`;
|
|
formattedResult.style.display = "none";
|
|
});
|
|
}
|
|
|
|
function lookupMyIP() {
|
|
const ipInput = document.getElementById("ip-input").value.trim();
|
|
const resultDiv = document.getElementById("result");
|
|
const formattedResult = document.getElementById("formatted-result");
|
|
const hostnameData = document.getElementById("hostname-data");
|
|
const ipDataTable = document.getElementById("ip-data-table");
|
|
const apiLink = document.getElementById("api-link");
|
|
|
|
// if (!ipInput) {
|
|
// resultDiv.textContent = "Please enter an IP address";
|
|
// formattedResult.style.display = "none";
|
|
// return;
|
|
// }
|
|
|
|
resultDiv.textContent = "Loading...";
|
|
formattedResult.style.display = "none";
|
|
|
|
fetch("/my")
|
|
.then((response) => {
|
|
return response.json();
|
|
})
|
|
.then((data) => {
|
|
resultDiv.textContent = JSON.stringify(data, null, 2);
|
|
|
|
// Clear previous data
|
|
hostnameData.innerHTML = "";
|
|
ipDataTable.innerHTML = "";
|
|
|
|
// Format hostname information
|
|
if (data.hostname) {
|
|
hostnameData.innerHTML = `<p><strong>IP:</strong> ${data.ip}</p>
|
|
<p><strong>Hostname:</strong> ${data.hostname}</p>`;
|
|
} else {
|
|
hostnameData.innerHTML = `<p><strong>IP:</strong> ${data.ip}</p>
|
|
<p><strong>Hostname:</strong> <em>No hostname found</em></p>`;
|
|
}
|
|
|
|
// Format IP data table
|
|
let tableHTML = `<tr>
|
|
<th>Property</th>
|
|
<th>Value</th>
|
|
</tr>`;
|
|
|
|
if (data.asn)
|
|
tableHTML += `<tr><td>ASN</td><td>${data.asn}</td></tr>`;
|
|
if (data.as_name)
|
|
tableHTML += `<tr><td>AS Name</td><td>${data.as_name}</td></tr>`;
|
|
if (data.country_code)
|
|
tableHTML += `<tr><td>Country Code</td><td>${data.country_code}</td></tr>`;
|
|
if (data.country)
|
|
tableHTML += `<tr><td>Country</td><td>${data.country}</td></tr>`;
|
|
if (data.region)
|
|
tableHTML += `<tr><td>Region</td><td>${data.region}</td></tr>`;
|
|
if (data.city)
|
|
tableHTML += `<tr><td>City</td><td>${data.city}</td></tr>`;
|
|
if (data.latitude)
|
|
tableHTML += `<tr><td>Latitude</td><td>${data.latitude}</td></tr>`;
|
|
if (data.longitude)
|
|
tableHTML += `<tr><td>Longitude</td><td>${data.longitude}</td></tr>`;
|
|
if (data.zip_code)
|
|
tableHTML += `<tr><td>ZIP Code</td><td>${data.zip_code}</td></tr>`;
|
|
if (data.time_zone)
|
|
tableHTML += `<tr><td>Time Zone</td><td>${data.time_zone}</td></tr>`;
|
|
|
|
ipDataTable.innerHTML = tableHTML;
|
|
|
|
// Show formatted result
|
|
formattedResult.style.display = "block";
|
|
document.getElementById("ip-input").value = data.ip;
|
|
|
|
apiLink.textContent = `https://ip.unbots.ru/${data.ip}`;
|
|
apiLink.href = `https://ip.unbots.ru/${data.ip}`;
|
|
});
|
|
}
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
lookupMyIP();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|