Spaces:
Running
Running
Commit ·
0bcdffe
1
Parent(s): 31d903b
Trust
Browse files- index.html +72 -81
- script.js +59 -0
- style.css +41 -17
index.html
CHANGED
|
@@ -1,82 +1,73 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html lang="
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
data.choices?.[0]?.message?.content || 'No response received.';
|
| 75 |
-
responseDiv.innerHTML = marked.parse(markdownText);
|
| 76 |
-
} catch (error) {
|
| 77 |
-
responseDiv.innerHTML = 'Error: ' + error.message;
|
| 78 |
-
}
|
| 79 |
-
}
|
| 80 |
-
</script>
|
| 81 |
-
</body>
|
| 82 |
-
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="id">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Ark Re Code Scraper</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div class="container">
|
| 11 |
+
<h1>Ark Re Code Scraper</h1>
|
| 12 |
+
|
| 13 |
+
<label for="charName">Cari Karakter:</label>
|
| 14 |
+
<input type="text" id="charName" placeholder="Masukkan nama karakter...">
|
| 15 |
+
<button onclick="fetchData()">Cari</button>
|
| 16 |
+
|
| 17 |
+
<div id="result"></div>
|
| 18 |
+
</div>
|
| 19 |
+
|
| 20 |
+
<script>
|
| 21 |
+
async function fetchData() {
|
| 22 |
+
const charName = document.getElementById("charName").value;
|
| 23 |
+
const resultDiv = document.getElementById("result");
|
| 24 |
+
|
| 25 |
+
if (!charName) {
|
| 26 |
+
resultDiv.innerHTML = "<p>Masukkan nama karakter terlebih dahulu!</p>";
|
| 27 |
+
return;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
try {
|
| 31 |
+
const response = await fetch(`http://localhost:3000/api?name=${charName}`);
|
| 32 |
+
const data = await response.json();
|
| 33 |
+
|
| 34 |
+
if (data.error) {
|
| 35 |
+
resultDiv.innerHTML = `<p>${data.error}</p>`;
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
let output = "<h2>Hasil Pencarian:</h2>";
|
| 40 |
+
|
| 41 |
+
if (data.skills) {
|
| 42 |
+
output += `<h3>Skill & Discipline</h3>`;
|
| 43 |
+
output += `<p>Karakter: ${data.skills.Karakter}</p>`;
|
| 44 |
+
output += `<p>Link Skill 3: <a href="${data.skills.Skill3}" target="_blank">${data.skills.Skill3}</a></p>`;
|
| 45 |
+
output += `<p>Link Idle + Tap: <a href="${data.skills.Tap}" target="_blank">${data.skills.Tap}</a></p>`;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if (data.story) {
|
| 49 |
+
output += `<h3>Story Part II</h3>`;
|
| 50 |
+
output += `<p>Member: ${data.story.Member}</p>`;
|
| 51 |
+
output += `<p>Video: <a href="${data.story.Video}" target="_blank">${data.story.Video}</a></p>`;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
if (data.chatAnimations) {
|
| 55 |
+
output += `<h3>Chat Animations</h3>`;
|
| 56 |
+
output += `<p>Karakter: ${data.chatAnimations.Karakter}</p>`;
|
| 57 |
+
output += `<p>Video: <a href="${data.chatAnimations.Video}" target="_blank">${data.chatAnimations.Video}</a></p>`;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
if (data.illustration) {
|
| 61 |
+
output += `<h3>Illustrations</h3>`;
|
| 62 |
+
output += `<p>Karakter: ${data.illustration.Karakter}</p>`;
|
| 63 |
+
output += `<img src="${data.illustration.Image}" alt="Illustration" width="300">`;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
resultDiv.innerHTML = output;
|
| 67 |
+
} catch (error) {
|
| 68 |
+
resultDiv.innerHTML = "<p>Gagal mengambil data.</p>";
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
</script>
|
| 72 |
+
</body>
|
| 73 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
script.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const express = require("express");
|
| 2 |
+
const cors = require("cors");
|
| 3 |
+
const fetch = require("node-fetch");
|
| 4 |
+
const cheerio = require("cheerio");
|
| 5 |
+
|
| 6 |
+
const app = express();
|
| 7 |
+
app.use(cors());
|
| 8 |
+
|
| 9 |
+
const headers = {
|
| 10 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
async function fetchHtml(url) {
|
| 14 |
+
const response = await fetch(url, { headers });
|
| 15 |
+
return response.text();
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function parseData(cari, html) {
|
| 19 |
+
const $ = cheerio.load(html);
|
| 20 |
+
const rows = $("tr").slice(1);
|
| 21 |
+
let result = null;
|
| 22 |
+
|
| 23 |
+
rows.each((index, row) => {
|
| 24 |
+
const cols = $(row).find("td");
|
| 25 |
+
const characterName = $(cols[0]).find("a").text().trim();
|
| 26 |
+
let skill3Link = $(cols[2]).find("a[href*='SK3']").attr("href") || "";
|
| 27 |
+
let tapLink = $(cols[3]).find("a[href*='Tap']").attr("href") || "";
|
| 28 |
+
|
| 29 |
+
if (characterName.includes(cari)) {
|
| 30 |
+
result = { Karakter: characterName, Skill3: skill3Link, Tap: tapLink };
|
| 31 |
+
return false; // Keluar dari loop
|
| 32 |
+
}
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
return result;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
app.get("/api", async (req, res) => {
|
| 39 |
+
const cari = req.query.name;
|
| 40 |
+
if (!cari) return res.json({ error: "Masukkan nama karakter!" });
|
| 41 |
+
|
| 42 |
+
const url = "https://arkrecodewiki.miraheze.org/wiki/Love_Link";
|
| 43 |
+
try {
|
| 44 |
+
const html = await fetchHtml(url);
|
| 45 |
+
const segments = html.split("Show Spoilers");
|
| 46 |
+
|
| 47 |
+
if (segments.length < 7) return res.json({ error: "Data tidak ditemukan" });
|
| 48 |
+
|
| 49 |
+
const skillData = parseData(cari, segments[1]);
|
| 50 |
+
|
| 51 |
+
res.json({ skills: skillData || "Tidak ditemukan" });
|
| 52 |
+
} catch (error) {
|
| 53 |
+
res.json({ error: "Gagal mengambil data" });
|
| 54 |
+
}
|
| 55 |
+
});
|
| 56 |
+
|
| 57 |
+
app.listen(3000, () => {
|
| 58 |
+
console.log("Server berjalan di http://localhost:3000");
|
| 59 |
+
});
|
style.css
CHANGED
|
@@ -1,28 +1,52 @@
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
h1 {
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 28 |
}
|
|
|
|
| 1 |
body {
|
| 2 |
+
font-family: Arial, sans-serif;
|
| 3 |
+
background-color: #f0f0f0;
|
| 4 |
+
text-align: center;
|
| 5 |
+
padding: 20px;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.container {
|
| 9 |
+
background: white;
|
| 10 |
+
padding: 20px;
|
| 11 |
+
border-radius: 10px;
|
| 12 |
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
| 13 |
+
max-width: 500px;
|
| 14 |
+
margin: auto;
|
| 15 |
}
|
| 16 |
|
| 17 |
h1 {
|
| 18 |
+
font-size: 22px;
|
| 19 |
+
color: #333;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
input {
|
| 23 |
+
width: 80%;
|
| 24 |
+
padding: 8px;
|
| 25 |
+
margin: 10px 0;
|
| 26 |
+
border: 1px solid #ccc;
|
| 27 |
+
border-radius: 5px;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
button {
|
| 31 |
+
background: #007bff;
|
| 32 |
+
color: white;
|
| 33 |
+
padding: 8px 15px;
|
| 34 |
+
border: none;
|
| 35 |
+
cursor: pointer;
|
| 36 |
+
border-radius: 5px;
|
| 37 |
}
|
| 38 |
|
| 39 |
+
button:hover {
|
| 40 |
+
background: #0056b3;
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
+
#result {
|
| 44 |
+
margin-top: 15px;
|
| 45 |
+
text-align: left;
|
| 46 |
+
padding: 10px;
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
+
img {
|
| 50 |
+
border-radius: 5px;
|
| 51 |
+
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
|
| 52 |
}
|