Taking website screenshot, server-side, on a Linux rented server, free

前端 未结 5 1682
清歌不尽
清歌不尽 2020-12-14 04:08

Ok so, right now I can\'t really afford to pay for any service. I want to be able to take screenshots using my rented server, which is Linux based, and output them on the sc

相关标签:
5条回答
  • 2020-12-14 04:46

    Here is a better script using phantomJS 1.5

    var page = require('webpage').create();
    
    page.open('http://www.google.com', function() {
    
        page.viewportSize = {width: 1024, height: 768};
        page.render('screenshot.png');
        phantom.exit();
    });
    
    0 讨论(0)
  • 2020-12-14 04:50

    Since you have your own Linux server, the best way is to run your own screenshot service without limitation. Here is an easy solution to run it on your server: https://github.com/filovirid/screenshot_server

    It creates an API so that you can access it from everywhere.

    0 讨论(0)
  • 2020-12-14 04:51

    One of the solutions in 2017:

    https://github.com/GoogleChrome/puppeteer

    example:

    const puppeteer = require('puppeteer');
    
    (async() => {
    
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto('https://example.com');
    await page.screenshot({path: 'example.png'});
    
    browser.close();
    })();
    
    0 讨论(0)
  • 2020-12-14 04:52

    PhantomJs is the solution

    if(phantom.state.length === 0){
      phantom.state = '0_home';
      phantom.open('http://www.mini.de');
    }
    else if(phantom.state === '0_home'){
      phantom.viewportSize = {width: 800, height: 600};
      phantom.sleep(2000);
      phantom.render('home.png');
      phantom.exit(0);
    }
    
    0 讨论(0)
  • 2020-12-14 05:08

    http://cutycapt.sourceforge.net/

    CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP.

    There is no PHP-api, but you can always use it through PHP's exec functions.

    0 讨论(0)
提交回复
热议问题