connorlixyz commited on
Commit
17f182a
1 Parent(s): a084eac

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +12 -0
  2. index.html +66 -0
  3. index.js +83 -0
  4. package.json +21 -0
Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY . .
6
+
7
+ EXPOSE 7860
8
+
9
+ RUN apt update -y &&\
10
+ npm install
11
+
12
+ CMD ["node", "index.js"]
index.html ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>蜀 道 难</title>
6
+ <style>
7
+ body {
8
+ font-family: Arial, sans-serif;
9
+ text-align: center;
10
+ background-color: #f0f0f0;
11
+ }
12
+ header {
13
+ background-color: #4a4a4a;
14
+ color: #fff;
15
+ padding: 2px;
16
+ }
17
+ h1 {
18
+ font-size: 36px;
19
+ }
20
+ #content {
21
+ max-width: 800px;
22
+ margin: 0 auto;
23
+ padding: 20px;
24
+ background-color: #fff;
25
+ border-radius: 5px;
26
+ }
27
+ p {
28
+ font-size: 18px;
29
+ line-height: 1.5;
30
+ }
31
+ </style>
32
+ </head>
33
+ <body>
34
+ <header>
35
+ <h1>蜀道难</h1>
36
+ </header>
37
+ <div id="content">
38
+ <p>噫吁嚱,危乎高哉!</p>
39
+ <p>蜀道之难,难于上青天!</p>
40
+ <p>蚕丛及鱼凫,开国何茫然!</p>
41
+ <p>尔来四万八千岁,不与秦塞通人烟。</p>
42
+ <p>西当太白有鸟道,可以横绝峨眉巅。</p>
43
+ <p>地崩山摧壮士死,然后天梯石栈相钩连。</p>
44
+ <p>上有六龙回日之高标,下有冲波逆折之回川。</p>
45
+ <p>黄鹤之飞尚不得过,猿猱欲度愁攀援。</p>
46
+ <p>青泥何盘盘,百步九折萦岩峦。</p>
47
+ <p>扪参历井仰胁息,以手抚膺坐长叹。</p>
48
+ <br></br>
49
+ <p>问君西游何时还?畏途巉岩不可攀。</p>
50
+ <p>但见悲鸟号古木,雄飞雌从绕林间。</p>
51
+ <p>又闻子规啼夜月,愁空山。</p>
52
+ <p>蜀道之难,难于上青天,使人听此凋朱颜!</p>
53
+ <p>连峰去天不盈尺,枯松倒挂倚绝壁。</p>
54
+ <p>飞湍瀑流争喧豗,砯崖转石万壑雷。</p>
55
+ <p>其险也如此,嗟尔远道之人胡为乎来哉!(也如此 一作:也若此)</p>
56
+ <br></br>
57
+ <p>剑阁峥嵘而崔嵬,一夫当关,万夫莫开。</p>
58
+ <p>所守或匪亲,化为狼与豺。</p>
59
+ <p>朝避猛虎,夕避长蛇,磨牙吮血,杀人如麻。</p>
60
+ <p>锦城虽云乐,不如早还家。</p>
61
+ <p>蜀道之难,难于上青天,侧身西望长咨嗟!</p>
62
+
63
+
64
+ </div>
65
+ </body>
66
+ </html>
index.js ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const axios = require('axios');
2
+ const fs = require('fs');
3
+ const cron = require('node-cron');
4
+ const http = require('http');
5
+ const path = require('path');
6
+ const port = process.env.PORT || 7860;
7
+
8
+ // 定义要访问的网页URL数组
9
+ const urls = [
10
+ //huggingface
11
+ 'https://connorlixyz-autoliveformcst.hf.space', // huggingface-本项目
12
+ //Goorm
13
+ 'https://my-nodejs-ivzud.run-us-west2.goorm.site', // Goorm-linshi
14
+ 'https://ide-run.goorm.io/workspace/d8MS7D1BaRxuHgRKnSW?token=ada5536dbe5768f245c935ab547af078&guestname=0123', // MC-servers-py
15
+
16
+
17
+ // 添加更多的URL
18
+ ];
19
+
20
+ // 创建日志文件
21
+ //const logFile = 'visit-log.txt';
22
+
23
+ // 访问网页并将结果写入日志
24
+ async function scrapeAndLog(url) {
25
+ try {
26
+ const response = await axios.get(url, {
27
+ headers: {
28
+ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36',
29
+ 'Referer': 'https://ide-run.goorm.io/workspace/d8MS7D1BaRxuHgRKnSW?token=ada5536dbe5768f245c935ab547af078&guestname=0123',
30
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
31
+ 'Cookie': 'goormaccounts.sid=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDQwMDkzNTQsIlRva2VuVHlwZSI6ImxldmVsMSIsImlkIjoibWlpODc4ajFjX2d1ZXN0IiwiZW1haWwiOiJtaWk4NzhqMWNfZ3Vlc3QiLCJjcmVhdGVkYXRlIjoxNzAzNDA0NTU0LCJzZXNzaW9uaWQiOiJHcHcxRW50ZWViOW9jaFFNa0p0cm5UaXdUNjRWSTlrSHM3RDUtTDFWRUhFPSIsIlRUTCI6MH0.i1TQxQGjA2zoA6XzfEHButaskPFB9OPw-2t7I9nQjkZT7Kp6U4q5KvcfUdATRvHOl9_7ivnF2f-zRl2cIj1QsYxCUE9n08fqjCUQAsdHOufQniyo2ubPxwnZeY8Q2NENJOdo-S_yKIFxAJmkzp39WnczpU9ECMyvpGSaW-kgO6cOc1rhpG8Qw8y4Bxujg_Y7WPsu4P2_lm94Ra82STo9J_ackAuYt07DNPGv8dewwqUJl2Mol1IR0V7or2snALG7ZJaxDOV5F-dpCgxyjoxp4nZu9HSAZ1ZJW2wa2JCN4KNkQmr2E1a_spxXtKuFagF0FX58GHs0bFIpHdVnB9os6A; io=LrGg71rINtQ8vOvRABdF; ch-veil-id=fd2d2bdb-49f9-4ef2-83bf-f8a138b60994; ch-session-90340=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzZXMiLCJrZXkiOiI5MDM0MC02NTg3ZTQ0MzZhNjg3NDc2MWE2MiIsImlhdCI6MTcwMzQwNDYxMSwiZXhwIjoxNzA1OTk2NjExfQ.jGjxAoNOU20W00r_lL2EFrOS4snMkw13Im406CIuZTs; AWSALB=qVOqrbXrCdgN5OcOdYA+TcNy7NL/45KrHER8B11QKkNbA4/EX+H7uPuKlsWup3Mu9pYvZC3/vT5HG+Z3I3C8WjNRV8Q+hRLikr6AbUCv+TvLFsqCxjFNaB+QcQeL; AWSALBCORS=qVOqrbXrCdgN5OcOdYA+TcNy7NL/45KrHER8B11QKkNbA4/EX+H7uPuKlsWup3Mu9pYvZC3/vT5HG+Z3I3C8WjNRV8Q+hRLikr6AbUCv+TvLFsqCxjFNaB+QcQeL; ide.goorm.sid=s%3AE7z7m6YxTo_GhQtyl9EH_uBKJKKnnILr.wFxZrrH%2BSLBFIUh%2BjrS0YYotEDdcLGCqRH%2Fbn33xANc'
32
+ }
33
+ });
34
+ const timestamp = new Date().toISOString();
35
+ const logMessage = `${timestamp}: Web visited Successfully ${url}\n`;
36
+
37
+ // 将访问结果写入日志文件
38
+ // fs.appendFileSync(logFile, logMessage);
39
+
40
+ console.log(logMessage);
41
+ } catch (error) {
42
+ const timestamp = new Date().toISOString();
43
+ const errorMessage = `${timestamp}: Web visited Error ${url}: ${error.message}\n`;
44
+
45
+ // 将错误信息写入日志文件
46
+ // fs.appendFileSync(logFile, errorMessage);
47
+
48
+ console.error(errorMessage);
49
+ }
50
+ }
51
+
52
+ // 使用cron来安排定期任务
53
+ cron.schedule('0 */2 * * * *', () => {
54
+ console.log('Running webpage access...');
55
+ // 循环访问每个URL
56
+ urls.forEach((url) => {
57
+ scrapeAndLog(url);
58
+ });
59
+ });
60
+
61
+
62
+ const server = http.createServer((req, res) => {
63
+ if (req.url === '/') {
64
+ const filePath = path.join(__dirname, 'index.html');
65
+
66
+ fs.readFile(filePath, (err, data) => {
67
+ if (err) {
68
+ res.writeHead(500);
69
+ res.end('Error loading index.html');
70
+ } else {
71
+ res.writeHead(200, { 'Content-Type': 'text/html' });
72
+ res.end(data);
73
+ }
74
+ });
75
+ } else {
76
+ res.writeHead(404);
77
+ res.end('Not Found');
78
+ }
79
+ });
80
+
81
+ server.listen(port, () => {
82
+ console.log(`Server is running on port ${port}`);
83
+ });
package.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "auto-keep",
3
+ "version": "1.0.0",
4
+ "description": "auto-keep",
5
+ "main": "index.js",
6
+ "author": "okka",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "scripts": {
10
+ "start": "node index.js"
11
+ },
12
+ "dependencies": {
13
+ "express": "^4.18.2",
14
+ "request": "^2.88.2",
15
+ "axios": "^1.5.0",
16
+ "node-cron": "^2.0.1"
17
+ },
18
+ "engines": {
19
+ "node": ">=14"
20
+ }
21
+ }