GilbertClaus commited on
Commit
0bcdffe
·
1 Parent(s): 31d903b
Files changed (3) hide show
  1. index.html +72 -81
  2. script.js +59 -0
  3. style.css +41 -17
index.html CHANGED
@@ -1,82 +1,73 @@
1
  <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>WSP ChatBot</title>
7
- <link
8
- rel="stylesheet"
9
- href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" />
10
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
11
- <style>
12
- #response {
13
- margin-top: 20px;
14
- padding: 10px;
15
- min-height: 50px;
16
- }
17
- #response h3 {
18
- color: #333;
19
- font-size: 1.2em;
20
- }
21
- #response strong {
22
- color: #d9534f;
23
- }
24
- #response ul {
25
- padding-left: 20px;
26
- }
27
- #response li {
28
- margin-bottom: 5px;
29
- }
30
- </style>
31
- </head>
32
- <body>
33
- <div class="container">
34
- <h2>Free ChatBot</h2>
35
- <div class="form-group">
36
- <input
37
- type="text"
38
- class="form-control"
39
- id="userInput"
40
- placeholder="Enter your question" />
41
- </div>
42
- <button class="btn btn-success" onclick="sendMessage()">Ask!</button>
43
- <div id="response"></div>
44
- </div>
45
- <script>
46
- async function sendMessage() {
47
- const input = document.getElementById('userInput').value;
48
- const responseDiv = document.getElementById('response');
49
- if (!input) {
50
- responseDiv.innerHTML = 'Please enter a message.';
51
- return;
52
- }
53
- responseDiv.innerHTML = 'Loading...';
54
- try {
55
- const response = await fetch(
56
- 'https://openrouter.ai/api/v1/chat/completions',
57
- {
58
- method: 'POST',
59
- headers: {
60
- Authorization: 'Bearer <API Key from Open Router>',
61
- 'HTTP-Referer': 'https://www.sitename.com',
62
- 'X-Title': 'SiteName',
63
- 'Content-Type': 'application/json',
64
- },
65
- body: JSON.stringify({
66
- model: 'deepseek/deepseek-r1:free',
67
- messages: [{ role: 'user', content: input }],
68
- }),
69
- },
70
- );
71
- const data = await response.json();
72
- console.log(data);
73
- const markdownText =
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
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
  h1 {
7
- font-size: 16px;
8
- margin-top: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
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
  }