Linux下使用命令行获取网页截图
环境准备
Linxu系统
centos 7
Python Version
Python 2.7.5
Git Version
1.8.3.1
安装Python-webkit2png[Git地址]
1 | git clone https://github.com/adamn/python-webkit2png.gitcd python-webkit2pngpython setup.py install |
安装PyQt4相关依赖(4.10.1-13.el7)
1 | yum install PyQt4.x86_64yum install PyQt4-devel.x86_64yum install PyQt4-webkit.x86_64yum install PyQt4-webkit-devel.noarch |
安装Xvfb(虚拟X server)
1 | yum install xorg-x11-server-Xvfb.x86_64 |
运行命令行
1 | webkit2png http://sina.com.cn -x 1280 1200 --output=home.png |
缺点
webkitpng
只能获取静态页面的截图,不能获取动态页面或者需要通过js计算之后的页面。