|
const axios = require('axios'); |
|
const fs = require('fs'); |
|
const cron = require('node-cron'); |
|
const http = require('http'); |
|
const path = require('path'); |
|
const port = process.env.PORT || 7860; |
|
|
|
|
|
const urls = [ |
|
|
|
'https://connorlixyz-fgdhguhkuautogdkeepgdlivegd45df.hf.space', |
|
'https://connorlixyz-autobaolikeeplive.hf.space', |
|
|
|
'https://antique-simplistic-pirate.glitch.me', |
|
'https://billowy-transparent-griffin.glitch.me', |
|
'https://zealous-tasty-canvas.glitch.me', |
|
'https://interesting-amazing-caption.glitch.me', |
|
'https://melted-lava-sweatpants.glitch.me', |
|
'https://achieved-kindhearted-address.glitch.me', |
|
|
|
'https://fdfgnodejs-argofhf.onrender.com', |
|
'https://yangnodeargokjgu.onrender.com', |
|
'https://adjgoodpluseufuj.onrender.com', |
|
'https://fsnodejs-eastdfh.onrender.com', |
|
'https://gdfhnodejssggudj.onrender.com', |
|
|
|
'https://my-first-js.osc-fr1.scalingo.io', |
|
'https://fhjhflinshifuyhalinshi.osc-fr1.scalingo.io', |
|
|
|
'http://nodejs-argo.liconnor.serv00.net:3079', |
|
'http://nezha-ws.liconnor.serv00.net:3080', |
|
'http://ndoejs-argo.acewong.serv00.net:13333', |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
async function scrapeAndLog(url) { |
|
try { |
|
const response = await axios.get(url, { |
|
headers: { |
|
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0', |
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' |
|
} |
|
}); |
|
const timestamp = new Date().toISOString(); |
|
const logMessage = `${timestamp}: Web visited Successfully ${url}\n`; |
|
|
|
|
|
|
|
|
|
console.log(logMessage); |
|
} catch (error) { |
|
const timestamp = new Date().toISOString(); |
|
const errorMessage = `${timestamp}: Web visited Error ${url}: ${error.message}\n`; |
|
|
|
|
|
|
|
|
|
console.error(errorMessage); |
|
} |
|
} |
|
|
|
|
|
cron.schedule('*/30 * * * * *', () => { |
|
console.log('Running webpage access...'); |
|
|
|
urls.forEach((url) => { |
|
scrapeAndLog(url); |
|
}); |
|
}); |
|
|
|
|
|
const server = http.createServer((req, res) => { |
|
if (req.url === '/') { |
|
const filePath = path.join(__dirname, 'index.html'); |
|
|
|
fs.readFile(filePath, (err, data) => { |
|
if (err) { |
|
res.writeHead(500); |
|
res.end('Error loading index.html'); |
|
} else { |
|
res.writeHead(200, { 'Content-Type': 'text/html' }); |
|
res.end(data); |
|
} |
|
}); |
|
} else { |
|
res.writeHead(404); |
|
res.end('Not Found'); |
|
} |
|
}); |
|
|
|
server.listen(port, () => { |
|
console.log(`Server is running on port ${port}`); |
|
}); |