1 Star 0 Fork 0

张志阳/Python截图服务

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>WebSocket Screenshot Client</title>
</head>
<body>
<h1>WebSocket Screenshot Client</h1>
<canvas id="screenshotCanvas" width="800" height="600"></canvas>
<script>
const ws = new WebSocket('ws://127.0.0.1:12345');
ws.onopen = () => {
console.log('Connected to the server');
// 开始请求截图
requestScreenshot();
};
ws.onmessage = event => {
const imgData = event.data;
const canvas = document.getElementById('screenshotCanvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.onload = function () {
ctx.drawImage(img, 0, 0);
// 继续请求新的截图
requestScreenshot();
};
img.src = `data:image/png;base64,${imgData}`;
};
function requestScreenshot() {
// 这里定义截图的区域
const x1 = 100;
const y1 = 100;
const x2 = 500;
const y2 = 500;
ws.send(`${x1},${y1},${x2},${y2}`);
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zhang-zhiyang/python-screenshot-service.git
git@gitee.com:zhang-zhiyang/python-screenshot-service.git
zhang-zhiyang
python-screenshot-service
Python截图服务
master

搜索帮助