Linux下使用命令行獲取網頁截圖
環境準備
Linxu系統
centos 7
Python Version
Python 2.7.5
Git Version
1.8.3.1
安裝Python-webkit2png[Git地址]
git clone https://github.com/adamn/python-webkit2png.git
cd python-webkit2png
python setup.py install
安裝PyQt4相關依賴(4.10.1-13.el7)
yum install PyQt4.x86_64
yum install PyQt4-devel.x86_64
yum install PyQt4-webkit.x86_64
yum install PyQt4-webkit-devel.noarch
安裝Xvfb(虛擬X server)
yum install xorg-x11-server-Xvfb.x86_64
運行命令行
webkit2png http://sina.com.cn -x 1280 1200 --output=home.png
缺點
webkitpng
只能獲取靜態頁面的截圖,不能獲取動態頁面或者需要通過js計算之後的頁面。