Create server.js
Browse files
server.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const axios = require('axios');
|
| 2 |
+
const express = require('express');
|
| 3 |
+
const cheerio = require('cheerio');
|
| 4 |
+
|
| 5 |
+
const app = express();
|
| 6 |
+
|
| 7 |
+
async function renderz() {
|
| 8 |
+
try {
|
| 9 |
+
let url = 'https://renderz.app/redeem-codes';
|
| 10 |
+
let response = await axios.get(url);
|
| 11 |
+
let $ = cheerio.load(response.data);
|
| 12 |
+
let codes = [];
|
| 13 |
+
$('.flex.flex-col.gap-4 button').each((index, element) => {
|
| 14 |
+
let reward = $(element).find('span.text-white.text-sm.font-bold')
|
| 15 |
+
.text().replace('Reward: ', '').trim();
|
| 16 |
+
let codeElement = $(element).find('div.text-white.font-bold').first();
|
| 17 |
+
codeElement.find('div').remove();
|
| 18 |
+
let code = codeElement.text().trim();
|
| 19 |
+
if (reward && code) {
|
| 20 |
+
codes.push({ reward, code });
|
| 21 |
+
}
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
return codes;
|
| 25 |
+
} catch (error) {
|
| 26 |
+
console.error('Gagal mengambil data:', error);
|
| 27 |
+
return [];
|
| 28 |
+
}
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
app.all('/', (req, res) => res.send(`<!DOCTYPE html>
|
| 32 |
+
<html>
|
| 33 |
+
<meta charset="UTF-8">
|
| 34 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 35 |
+
<link rel="stylesheet" href="https://nightly.link/style.css">
|
| 36 |
+
<title>FC Mobile Redeem Codes</title>
|
| 37 |
+
<body>
|
| 38 |
+
<article>
|
| 39 |
+
<h1>FC Mobile Redeem Codes</h1>
|
| 40 |
+
<h2>Redeem here <a href="https://redeem.fcm.ea.com">redeem.fcm.ea.com</a></h2>
|
| 41 |
+
<p>List of Code:</p>
|
| 42 |
+
<table id="codes-table"><tr><th>Reward</th><th>Code</th></tr></table>
|
| 43 |
+
</article>
|
| 44 |
+
<script>
|
| 45 |
+
async function fetchAndPopulateTable(){try{const r=await fetch('/v1/codes'),d=await r.json(),t=document.getElementById('codes-table');d.forEach(e=>{const o=t.insertRow();o.insertCell(0).textContent=e.reward,o.insertCell(1).textContent=e.code})}catch(r){console.error('Error fetching data:',r)}}document.addEventListener('DOMContentLoaded',fetchAndPopulateTable);
|
| 46 |
+
</script>
|
| 47 |
+
</body>
|
| 48 |
+
</html>`));
|
| 49 |
+
|
| 50 |
+
app.all('/v1/codes', async (req, res) => res.json(await renderz()));
|
| 51 |
+
|
| 52 |
+
app.listen(7860);
|