使用代码的网页特定部分的屏幕截图


Screenshot of specific section of a webpage using code

有没有一种方法可以在按下按钮时截图网页的特定部分,并将图像保存到我的服务器上?例如,当我按下按钮时,它会保存一个"屏幕截图",其中包含顶部:100顶部:800左侧:200左侧:700

之间的所有内容

您可以在我的一个项目中使用对我非常有用的javascript库html2canvas。这是一个样品。

html2canvas(document.body, {
    onrendered: function(canvas) {
        /* canvas is the actual canvas element,
           to append it to the page call for example
           document.body.appendChild( canvas );
        */
    }
});

这里是一个工作演示。

祝你好运。