';echo date('Y-m-d H:m:s')...}" Just take a screenshot.">
How to implement web page screenshots in PHP: first download CutyCapt; then unzip the tar package; finally use the code "public function index(){echo '
';echo date('Y-m-d H:m:s ')...}" Just take a screenshot.
Recommended: "PHP Video Tutorial"
Windows system##If you need to output the content of a URL into a view image, you need an auxiliary tool CutyCapt
to achieve this requirement
No need to click to install
public function index() { echo ''; echo date('Y-m-d H:m:s').'
'; $_GET['url'] = 'https://www.aliyun.com/jiaocheng/970387.html'; $url=$_GET["url"]; $imgName = rand(10000,99999); $out = 'D:/game/'.$imgName.'.png'; //输出图片地址 $path = 'D:/game/CutyCapt.exe'; //工具存储地址 $cmd = "$path --url=$url --out=$out"; echo $cmd.'
'; system($cmd, $em); if(!empty($em)){ echo '成功了呢'; }; echo date('Y-m-d H:m:s').'
'; }Copy after login
(If $cmd is executed directly from the command line, an error will be reported):
QIODevice::read: maxSize argument exceeds QByteArray size limit terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
Linux system CutyCapt is a screenshot tool Official website http://cutycapt.sourceforge.net /Processing
:
1. Start – Run – Enter cmd
2. Enter cd %windir%\system32 (enter the system32 folder in the Windows installation directory)
3. Enter Regsvr32 Msxml3.dll
4. Reason link
My main purpose is to solve the problem of using php to save web pages as pictures. Without further ado, start installing CutyCapt
yum install epel-release #依赖安装 yum install Xvfbyum install xorg-x11-fonts*yum install qtwebkit-devel qt-devel #中文字体 yum install fonts-chinese yum install CutyCapt #测试使用 xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.phpsong.com --out=phpsong.jpg 如果提示错误libEGL warning: DRI2: failed to open swrast (search paths /usr/lib64/dri)
yum install mesa-dri-drivers
2) The execution speed is slow
3) Intercepted Baidu and Komatsu blogs and found that the text on the button is not displayed, which should also be caused by garbled characters
xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.phpsong.com --out=1.jpg xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.baidu.com --out=2.jpg xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.163.com --out=3.jpg xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.sina.com.cn --out=4.jpg
The above is the detailed content of How to implement web page screenshots in PHP. For more information, please follow other related articles on the PHP Chinese website!