Skip to content

Commit

Permalink
添加云端截图模式,推送内容补充链接
Browse files Browse the repository at this point in the history
  • Loading branch information
easychen committed May 27, 2022
1 parent 8ee1665 commit 5f4866b
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 30 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@

## 最新版本

- 插件·Chrome/Edge:[2022.05.26.19.42](ckc.zip)
- 自架云端Docker镜像:2022.05.26.19.10
- 文档:2022.05.26.19.48
- 插件·Chrome/Edge:[2022.05.27.13.00](ckc.zip)
- 自架云端Docker镜像:2022.05.27.12.33
- 文档:2022.05.27.13.00
- 更新日志:[GitHub](https://github.com/easychen/checkchan-dist/commits/main)

自架云端 Docker 命令(`API Key``YouRAPiK1`):
自架云端 Docker 命令(`API Key``YouRAPiK1`替换成`任意你想要的安全密码不要带$`):

```bash
docker run -e API_KEY=YouRAPiK1 -e TZ=Asia/Chongqing -e ERROR_IMAGE=NORMAL -p 8088:80 -v $PWD:/data -d ccr.ccs.tencentyun.com/ftqq/checkchan:latest
```
* 特别提醒:`/data`挂载的目录需要写权限
* 特别提醒:后文有详细的安装帮助
* 特别提醒1:`/data`挂载的目录需要写权限
* 特别提醒2:此镜像为x86架构,arm架构镜像可[拉取源码](https://github.com/easychen/checkchan-dist/tree/main/docker)自行构建


Expand Down Expand Up @@ -208,6 +209,8 @@ services:
environment:
- API_KEY=<这里写一个你自己想的API_KEY>
- ERROR_IMAGE=NORMAL # NONE,NORMAL,FULL
- SNAP_URL_BASE=<开启截图在这里写服务器地址,不开留空> #如 http://ip.com/
- SNAP_FULL=1 #完整网页长图
- TZ=Asia/Chongqing
```
Expand Down Expand Up @@ -278,6 +281,20 @@ docker pull ccr.ccs.tencentyun.com/ftqq/checkchan:latest

Check酱也会每十分钟自动同步一次。

### 云端截图

Check酱自架云端支持对网页(dom)类型任务进行截图,可以通过给镜像传递环境变量来开启:

- SNAP_URL_BASE=<开启截图在这里写服务器地址,不开留空> #如 http://ip.com/
- SNAP_FULL=1 #完整网页长图

可参考上文的`docker-compser.yml`。添加环境变量后重启服务即可。

注意

- 截图功能需要较大的内存,部分服务器可能会报错
- 云端网络和本地不同,可能会超时失败,请适当增加延时,并将取消完整截图

### 云端任务的安全性

Check酱云端任务的原理是将cookie同步到云端,然后用浏览器查看,本质和用户操作一样。但因为出口IP可能是机房和数据中心,频次太高也有被风控的可能。如果将云端部署在家里,则和在家用电脑访问效果一样。
Expand Down
21 changes: 19 additions & 2 deletions README.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
- 文档:{doc-build}
- 更新日志:[GitHub](https://github.com/easychen/checkchan-dist/commits/main)

自架云端 Docker 命令(`API Key``YouRAPiK1`):
自架云端 Docker 命令(`API Key``YouRAPiK1`替换成`任意你想要的安全密码不要带$`):

```bash
docker run -e API_KEY=YouRAPiK1 -e TZ=Asia/Chongqing -e ERROR_IMAGE=NORMAL -p 8088:80 -v $PWD:/data -d ccr.ccs.tencentyun.com/ftqq/checkchan:latest
```
* 特别提醒:`/data`挂载的目录需要写权限
* 特别提醒:后文有详细的安装帮助
* 特别提醒1:`/data`挂载的目录需要写权限
* 特别提醒2:此镜像为x86架构,arm架构镜像可[拉取源码](https://github.com/easychen/checkchan-dist/tree/main/docker)自行构建


Expand Down Expand Up @@ -208,6 +209,8 @@ services:
environment:
- API_KEY=<这里写一个你自己想的API_KEY>
- ERROR_IMAGE=NORMAL # NONE,NORMAL,FULL
- SNAP_URL_BASE=<开启截图在这里写服务器地址,不开留空> #如 http://ip.com/
- SNAP_FULL=1 #完整网页长图
- TZ=Asia/Chongqing
```
Expand Down Expand Up @@ -278,6 +281,20 @@ docker pull ccr.ccs.tencentyun.com/ftqq/checkchan:latest

Check酱也会每十分钟自动同步一次。

### 云端截图

Check酱自架云端支持对网页(dom)类型任务进行截图,可以通过给镜像传递环境变量来开启:

- SNAP_URL_BASE=<开启截图在这里写服务器地址,不开留空> #如 http://ip.com/
- SNAP_FULL=1 #完整网页长图

可参考上文的`docker-compser.yml`。添加环境变量后重启服务即可。

注意

- 截图功能需要较大的内存,部分服务器可能会报错
- 云端网络和本地不同,可能会超时失败,请适当增加延时,并将取消完整截图

### 云端任务的安全性

Check酱云端任务的原理是将cookie同步到云端,然后用浏览器查看,本质和用户操作一样。但因为出口IP可能是机房和数据中心,频次太高也有被风控的可能。如果将云端部署在家里,则和在家用电脑访问效果一样。
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2022.05.26.19.42"
"2022.05.27.13.00"
Binary file modified ckc.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ services:
environment:
- API_KEY=aPiKe1
- ERROR_IMAGE=NORMAL # NONE,NORMAL,FULL
- SNAP_URL_BASE=http://... # NONE,NORMAL,FULL
- SNAP_FULL=1 # NONE,NORMAL,FULL
- TZ=Asia/Chongqing
2 changes: 1 addition & 1 deletion docker.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2022.05.26.19.10"
"2022.05.27.12.33"
2 changes: 1 addition & 1 deletion docker/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ app.post(`/monitor`, checkApiKey , async (req, res) => {
const cookies = req.body?.cookies ? JSON.parse(req.body.cookies) : get_cookies();
if( !item ) return res.json({"code":500,"message":"item格式不正确"});
const ret = await monitor_auto( item, cookies );
console.log( ret.status, ret.value, ret.type );
console.log( ret.status, ret.value, ret.type, ret.link );
return res.json(ret);

});
Expand Down
5 changes: 5 additions & 0 deletions docker/api/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ for( const item of to_checks )
let check_status = 0;
let check_content = "";
let check_html = "";
let check_link = "";

logit("checking..."+item.title, dayjs().format('YYYY-MM-DD HH:mm:ss'));

Expand All @@ -63,6 +64,7 @@ for( const item of to_checks )
{
check_content = ret.value;
if( ret.html ) check_html = ret.html;
if( ret.link ) check_link = ret.link;
check_status = 1;

}
Expand Down Expand Up @@ -161,6 +163,9 @@ for( const item of to_checks )
const title = '监测点['+item.title+']有新通知';

let desp = short(check_content,50) + (last_content && item.when == 'change' ? ('←' + short(last_content,50)):"");

const link = check_link || item.page || item.url;
desp += "\r\n\r\n [去看看]("+ link +") \r\n\r\n";

if( check_html )
desp += "\r\n\r\n---\r\n\r\n" + to_markdown(check_html);
Expand Down
49 changes: 39 additions & 10 deletions docker/api/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ exports.monitor_auto = async ( item, cookies ) =>
break;
case 'rss':
ret = await monitor_rss( item.url, (parseInt(item.delay)||3)*1000 );
return {status:!!(ret&&ret[item.rss_field]),value:ret[item.rss_field]||"",type:item.type};
return {status:!!(ret&&ret[item.rss_field]),value:ret[item.rss_field]||"",link:ret.link,type:item.type};
break;
case 'json':
// 特别注意,云端的json监测包含delay参数
Expand All @@ -184,8 +184,8 @@ exports.monitor_auto = async ( item, cookies ) =>
break;
case 'dom':
default:
ret = await monitor_dom( item.url, item.path, (parseInt(item.delay)||3)*1000, the_cookies );
return {status:!!(ret&&ret.text),value:ret.text||"",type:item.type,html:ret.html||""};
ret = await monitor_dom( item.url, item.path, (parseInt(item.delay)||3)*1000, the_cookies, item.id );
return {status:!!(ret&&ret.text),value:ret.text||"",type:item.type,html:ret.html||"",link:ret.link||""};
}
} catch (error) {
return {status:false,error,type:item.type};
Expand Down Expand Up @@ -285,14 +285,18 @@ async function monitor_dom_low(url, path, delay , cookies)
return {text:texts[0]||"",html,all};
}

async function monitor_dom(url, path, delay , cookies)
async function monitor_dom(url, path, delay , cookies, id)
{
const first = await monitor_dom_low(url, path, delay , cookies);
console.log( "low result" , first.text );
if( first && first.text ) return first;
if( !process.env.SNAP_URL_BASE )
{
const first = await monitor_dom_low(url, path, delay , cookies);
console.log( "low result" , first.text );
if( first && first.text ) return first;
}

let opt = {
args: ['--no-sandbox'],
defaultViewport: null,
headless: true,
};

Expand Down Expand Up @@ -335,11 +339,12 @@ async function monitor_dom(url, path, delay , cookies)
},path);
const { all,html, ...ret_short } = ret;
console.log("ret",ret_short);
// 如果返回值为空,那么截图

const image_dir = get_data_dir()+'/image';

// 如果返回值为空,那么保存错误现场
if( !(ret && ret.text) )
{
const image_dir = get_data_dir()+'/image';

if( !fs.existsSync(image_dir) )
fs.mkdirSync(image_dir);

Expand All @@ -356,9 +361,33 @@ async function monitor_dom(url, path, delay , cookies)
await page.screenshot({"path":image_dir+'/error.jpg',"type":"jpeg","captureBeyondViewport":false,"fullPage":process.env.ERROR_IMAGE=='FULL'||false});
}

}else
{
// 如果启用了返回截图功能
if( process.env.SNAP_URL_BASE )
{
if( !fs.existsSync(image_dir) )
fs.mkdirSync(image_dir);

const image_path = `${image_dir}/${id}.jpg`;

const mobile = puppeteer.devices['iPhone X']
await page.emulate(mobile);
await page.setViewport({ width:480, height:2000 });

await page.screenshot({"path":image_path,"type":"jpeg","captureBeyondViewport":false,"fullPage":process.env.SNAP_FULL||false});

if( fs.existsSync(image_path) )
{
console.log("截图完成");
ret.link = process.env.SNAP_URL_BASE + '/image/' + id +'.jpg?key='+process.env.API_KEY;
}
}
}





} catch (error) {
console.log("error",error);
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ services:
environment:
- API_KEY=aPiKe1
- ERROR_IMAGE=NORMAL # NONE,NORMAL,FULL
- SNAP_URL_BASE=http://... # NONE,NORMAL,FULL
- SNAP_FULL=1 # NONE,NORMAL,FULL
- TZ=Asia/Chongqing
25 changes: 20 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ <h1>Check酱</h1>
</ol>
<h2>最新版本</h2>
<ul>
<li>插件·Chrome/Edge:<a href="ckc.zip">2022.05.26.19.42</a></li>
<li>自架云端Docker镜像:2022.05.26.19.10</li>
<li>文档:2022.05.26.19.48</li>
<li>插件·Chrome/Edge:<a href="ckc.zip">2022.05.27.13.00</a></li>
<li>自架云端Docker镜像:2022.05.27.12.33</li>
<li>文档:2022.05.27.13.00</li>
<li>更新日志:<a href="https://github.com/easychen/checkchan-dist/commits/main">GitHub</a></li>
</ul>
<p>自架云端 Docker 命令(<code class="notranslate">API Key</code><code class="notranslate">YouRAPiK1</code>):</p>
<p>自架云端 Docker 命令(<code class="notranslate">API Key</code><code class="notranslate">YouRAPiK1</code>替换成<code class="notranslate">任意你想要的安全密码不要带$</code>):</p>
<div class="highlight highlight-source-shell"><pre>docker run -e API_KEY=YouRAPiK1 -e TZ=Asia/Chongqing -e ERROR_IMAGE=NORMAL -p 8088:80 -v <span class="pl-smi">$PWD</span>:/data -d ccr.ccs.tencentyun.com/ftqq/checkchan:latest</pre></div>
<ul>
<li>特别提醒:<code class="notranslate">/data</code>挂载的目录需要写权限</li>
<li>特别提醒:后文有详细的安装帮助</li>
<li>特别提醒1:<code class="notranslate">/data</code>挂载的目录需要写权限</li>
<li>特别提醒2:此镜像为x86架构,arm架构镜像可<a href="https://github.com/easychen/checkchan-dist/tree/main/docker">拉取源码</a>自行构建</li>
</ul>
<h2>什么是「Check酱」</h2>
Expand Down Expand Up @@ -131,6 +132,8 @@ <h4>通过 Docker-compose 启动</h4>
<span class="pl-ent">environment</span>:
- <span class="pl-s">API_KEY=&lt;这里写一个你自己想的API_KEY&gt;</span>
- <span class="pl-s">ERROR_IMAGE=NORMAL </span><span class="pl-c"><span class="pl-c">#</span> NONE,NORMAL,FULL</span>
- <span class="pl-s">SNAP_URL_BASE=&lt;开启截图在这里写服务器地址,不开留空&gt; </span><span class="pl-c"><span class="pl-c">#</span>如 http://ip.com/</span>
- <span class="pl-s">SNAP_FULL=1 </span><span class="pl-c"><span class="pl-c">#</span>完整网页长图</span>
- <span class="pl-s">TZ=Asia/Chongqing</span></pre></div>
<p>将其中 <code class="notranslate">&lt;这里写一个你自己想的API_KEY&gt;</code> 换成一个别人不知道的密码(下文称密码C<br>
)。注意不要包含<code class="notranslate">$</code>字符,替换完后也不再有两边的尖括号<code class="notranslate">&lt;&gt;</code></p>
Expand Down Expand Up @@ -164,6 +167,18 @@ <h3>同步本地任务到云端</h3>
<p>点击右上角 「云+箭头」的按钮,可以主动同步任务到云端。</p>
<p><a target="_blank" rel="noopener noreferrer" href="image/20220521145106.png"><img src="image/20220521145106.png" alt="" style="max-width: 100%;"></a></p>
<p>Check酱也会每十分钟自动同步一次。</p>
<h3>云端截图</h3>
<p>Check酱自架云端支持对网页(dom)类型任务进行截图,可以通过给镜像传递环境变量来开启:</p>
<ul>
<li>SNAP_URL_BASE=&lt;开启截图在这里写服务器地址,不开留空&gt; #如 <a href="http://ip.com/" rel="nofollow">http://ip.com/</a></li>
<li>SNAP_FULL=1 #完整网页长图</li>
</ul>
<p>可参考上文的<code class="notranslate">docker-compser.yml</code>。添加环境变量后重启服务即可。</p>
<p>注意</p>
<ul>
<li>截图功能需要较大的内存,部分服务器可能会报错</li>
<li>云端网络和本地不同,可能会超时失败,请适当增加延时,并将取消完整截图</li>
</ul>
<h3>云端任务的安全性</h3>
<p>Check酱云端任务的原理是将cookie同步到云端,然后用浏览器查看,本质和用户操作一样。但因为出口IP可能是机房和数据中心,频次太高也有被风控的可能。如果将云端部署在家里,则和在家用电脑访问效果一样。</p>
<h3>云端错误排查</h3>
Expand Down
25 changes: 20 additions & 5 deletions readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ <h1>Check酱</h1>
</ol>
<h2>最新版本</h2>
<ul>
<li>插件·Chrome/Edge:<a href="ckc.zip">2022.05.26.19.42</a></li>
<li>自架云端Docker镜像:2022.05.26.19.10</li>
<li>文档:2022.05.26.19.48</li>
<li>插件·Chrome/Edge:<a href="ckc.zip">2022.05.27.13.00</a></li>
<li>自架云端Docker镜像:2022.05.27.12.33</li>
<li>文档:2022.05.27.13.00</li>
<li>更新日志:<a href="https://github.com/easychen/checkchan-dist/commits/main">GitHub</a></li>
</ul>
<p>自架云端 Docker 命令(<code class="notranslate">API Key</code><code class="notranslate">YouRAPiK1</code>):</p>
<p>自架云端 Docker 命令(<code class="notranslate">API Key</code><code class="notranslate">YouRAPiK1</code>替换成<code class="notranslate">任意你想要的安全密码不要带$</code>):</p>
<div class="highlight highlight-source-shell"><pre>docker run -e API_KEY=YouRAPiK1 -e TZ=Asia/Chongqing -e ERROR_IMAGE=NORMAL -p 8088:80 -v <span class="pl-smi">$PWD</span>:/data -d ccr.ccs.tencentyun.com/ftqq/checkchan:latest</pre></div>
<ul>
<li>特别提醒:<code class="notranslate">/data</code>挂载的目录需要写权限</li>
<li>特别提醒:后文有详细的安装帮助</li>
<li>特别提醒1:<code class="notranslate">/data</code>挂载的目录需要写权限</li>
<li>特别提醒2:此镜像为x86架构,arm架构镜像可<a href="https://github.com/easychen/checkchan-dist/tree/main/docker">拉取源码</a>自行构建</li>
</ul>
<h2>什么是「Check酱」</h2>
Expand Down Expand Up @@ -120,6 +121,8 @@ <h4>通过 Docker-compose 启动</h4>
<span class="pl-ent">environment</span>:
- <span class="pl-s">API_KEY=&lt;这里写一个你自己想的API_KEY&gt;</span>
- <span class="pl-s">ERROR_IMAGE=NORMAL </span><span class="pl-c"><span class="pl-c">#</span> NONE,NORMAL,FULL</span>
- <span class="pl-s">SNAP_URL_BASE=&lt;开启截图在这里写服务器地址,不开留空&gt; </span><span class="pl-c"><span class="pl-c">#</span>如 http://ip.com/</span>
- <span class="pl-s">SNAP_FULL=1 </span><span class="pl-c"><span class="pl-c">#</span>完整网页长图</span>
- <span class="pl-s">TZ=Asia/Chongqing</span></pre></div>
<p>将其中 <code class="notranslate">&lt;这里写一个你自己想的API_KEY&gt;</code> 换成一个别人不知道的密码(下文称密码C<br>
)。注意不要包含<code class="notranslate">$</code>字符,替换完后也不再有两边的尖括号<code class="notranslate">&lt;&gt;</code></p>
Expand Down Expand Up @@ -153,6 +156,18 @@ <h3>同步本地任务到云端</h3>
<p>点击右上角 「云+箭头」的按钮,可以主动同步任务到云端。</p>
<p><a target="_blank" rel="noopener noreferrer" href="image/20220521145106.png"><img src="image/20220521145106.png" alt="" style="max-width: 100%;"></a></p>
<p>Check酱也会每十分钟自动同步一次。</p>
<h3>云端截图</h3>
<p>Check酱自架云端支持对网页(dom)类型任务进行截图,可以通过给镜像传递环境变量来开启:</p>
<ul>
<li>SNAP_URL_BASE=&lt;开启截图在这里写服务器地址,不开留空&gt; #如 <a href="http://ip.com/" rel="nofollow">http://ip.com/</a></li>
<li>SNAP_FULL=1 #完整网页长图</li>
</ul>
<p>可参考上文的<code class="notranslate">docker-compser.yml</code>。添加环境变量后重启服务即可。</p>
<p>注意</p>
<ul>
<li>截图功能需要较大的内存,部分服务器可能会报错</li>
<li>云端网络和本地不同,可能会超时失败,请适当增加延时,并将取消完整截图</li>
</ul>
<h3>云端任务的安全性</h3>
<p>Check酱云端任务的原理是将cookie同步到云端,然后用浏览器查看,本质和用户操作一样。但因为出口IP可能是机房和数据中心,频次太高也有被风控的可能。如果将云端部署在家里,则和在家用电脑访问效果一样。</p>
<h3>云端错误排查</h3>
Expand Down

1 comment on commit 5f4866b

@vercel
Copy link

@vercel vercel bot commented on 5f4866b May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

checkchan-dist – ./

checkchan-dist-morexmore.vercel.app
ckc.ftqq.com
checkchan-dist-git-main-morexmore.vercel.app

Please sign in to comment.