Website screenshots

前端 未结 26 3468
长发绾君心
长发绾君心 2020-11-21 06:07

Is there any way of taking a screenshot of a website in PHP, then saving it to a file?

26条回答
  •  无人及你
    2020-11-21 06:55

    Since PHP 5.2.2 it is possible, to capture a website with PHP solely!

    imagegrabscreen — Captures the whole screen

    
    

    imagegrabwindow - Grabs a window or its client area using a windows handle (HWND property in COM instance)

    HWND;
    $Browser->Visible = true;
    $Browser->Fullscreen = true;
    $Browser->Navigate('http://www.stackoverflow.com');
    
    while($Browser->Busy){
      com_message_pump(4000);
    }
    
    $img = imagegrabwindow($Browserhandle, 0);
    $Browser->Quit();
    imagepng($img, 'screenshot.png');
    ?>
    

    Edit: Note, these functions are available on Windows systems ONLY!

提交回复
热议问题