1. <small id='vVCod'></small><noframes id='vVCod'>

    <i id='vVCod'><tr id='vVCod'><dt id='vVCod'><q id='vVCod'><span id='vVCod'><b id='vVCod'><form id='vVCod'><ins id='vVCod'></ins><ul id='vVCod'></ul><sub id='vVCod'></sub></form><legend id='vVCod'></legend><bdo id='vVCod'><pre id='vVCod'><center id='vVCod'></center></pre></bdo></b><th id='vVCod'></th></span></q></dt></tr></i><div id='vVCod'><tfoot id='vVCod'></tfoot><dl id='vVCod'><fieldset id='vVCod'></fieldset></dl></div>
      <bdo id='vVCod'></bdo><ul id='vVCod'></ul>

    <tfoot id='vVCod'></tfoot>

  2. <legend id='vVCod'><style id='vVCod'><dir id='vVCod'><q id='vVCod'></q></dir></style></legend>

    1. Phantomjs - 截取网页截图

      时间:2023-09-06
        <tbody id='k1FUa'></tbody>
        <bdo id='k1FUa'></bdo><ul id='k1FUa'></ul>
      • <tfoot id='k1FUa'></tfoot>
      • <small id='k1FUa'></small><noframes id='k1FUa'>

            • <legend id='k1FUa'><style id='k1FUa'><dir id='k1FUa'><q id='k1FUa'></q></dir></style></legend>
                <i id='k1FUa'><tr id='k1FUa'><dt id='k1FUa'><q id='k1FUa'><span id='k1FUa'><b id='k1FUa'><form id='k1FUa'><ins id='k1FUa'></ins><ul id='k1FUa'></ul><sub id='k1FUa'></sub></form><legend id='k1FUa'></legend><bdo id='k1FUa'><pre id='k1FUa'><center id='k1FUa'></center></pre></bdo></b><th id='k1FUa'></th></span></q></dt></tr></i><div id='k1FUa'><tfoot id='k1FUa'></tfoot><dl id='k1FUa'><fieldset id='k1FUa'></fieldset></dl></div>

                本文介绍了Phantomjs - 截取网页截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个 URL(例如 http://www.example.com/OtterBox-77-24444-Commuter-Series-Optimus/dp/B00A21KPEI/ref=pd_sim_cps_4)并且想要截取它并在我的网页上预览.意思是,用户点击预览按钮,PhantomJS 需要将网页预览为 PNG/JPEG

                I have a URL (for e.g. http://www.example.com/OtterBox-77-24444-Commuter-Series-Optimus/dp/B00A21KPEI/ref=pd_sim_cps_4) and want to take a screenshot of it and preview it on my web page. Meaning, the user clicks on the preview button and PhantomJS needs to preview the web page as PNG/JPEG

                我也可以使用任何其他开源软件.

                I'm ok with using any other open source too.

                推荐答案

                我假设你已经安装了 Phantomjs 并在你的 .bashrc 中创建了一个别名,或者已经更新了你的系统路径来调用 Phantomjs 二进制文件.如果没有,您需要仔细阅读一些初学者教程:http://net.tutsplus.com/tutorials/javascript-ajax/testing-javascript-with-phantomjs/

                I am going to assume you have installed Phantomjs and have created an alias in your .bashrc or have updated your system path to call the Phantomjs binaries. If not, you need to peruse a few beginner tutorials: http://net.tutsplus.com/tutorials/javascript-ajax/testing-javascript-with-phantomjs/

                设置完成后,您需要编写一个简单的 javascript 文件,您将在终端(或 shell,如果您使用 Windows)中调用该文件.我将在下面提供一个简单的示例脚本.

                Once you have that set up, you will need to write a simple javascript file that you will call in the terminal (or shell, if you are using Windows). I will provide a simple, example script below.

                var WebPage = require('webpage');
                page = WebPage.create();
                page.open('http://google.com');
                page.onLoadFinished = function() {
                   page.render('googleScreenShot' + '.png');
                   phantom.exit();}
                

                然后,保存您的 js 文件.打开终端或 shell 并运行以下命令

                Then, save your js file. Open up your terminal or shell and run the following

                phantomjs yourFile.js
                

                就是这样.检查您调用 js 文件的目录,您应该有一个带有网页屏幕截图的 png 文件.

                That's it. Check the directory where you called the js file and you should have a png file with a screen shot of your web page.

                这非常简单,使用 phantomjs 有很多注意事项,但这是我能做到的最基础的.如果您需要 phantomjs 的其他配方,请尝试查看以下示例脚本:https://github.com/ariya/phantomjs/wiki/示例

                This is very simple and there are a lot of caveats to f-ing with phantomjs, but this is about as basic as I can make it. If you need other recipes for phantomjs, try looking at these example scripts: https://github.com/ariya/phantomjs/wiki/Examples

                这篇关于Phantomjs - 截取网页截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:当鼠标悬停在 Javascript 中时,棘手的按钮会移开? 下一篇:如何在没有服务器的情况下发送电子邮件?只有带有 sendgrid 的前端 Javascript 或

                相关文章

              1. <legend id='I2pZH'><style id='I2pZH'><dir id='I2pZH'><q id='I2pZH'></q></dir></style></legend>
              2. <tfoot id='I2pZH'></tfoot>

                <small id='I2pZH'></small><noframes id='I2pZH'>

                  <bdo id='I2pZH'></bdo><ul id='I2pZH'></ul>
                <i id='I2pZH'><tr id='I2pZH'><dt id='I2pZH'><q id='I2pZH'><span id='I2pZH'><b id='I2pZH'><form id='I2pZH'><ins id='I2pZH'></ins><ul id='I2pZH'></ul><sub id='I2pZH'></sub></form><legend id='I2pZH'></legend><bdo id='I2pZH'><pre id='I2pZH'><center id='I2pZH'></center></pre></bdo></b><th id='I2pZH'></th></span></q></dt></tr></i><div id='I2pZH'><tfoot id='I2pZH'></tfoot><dl id='I2pZH'><fieldset id='I2pZH'></fieldset></dl></div>