源码没有看,应该是用python封装了pyqtwebkit。
需要安装pyqt4(sudo apt-get install python-qt4)
简单示例
from ghost import Ghost
import time
def main():
ghost = Ghost()
start = time.time()
page, resources = ghost.open("http://www.baidu.com/")
end = time.time()
#保存了所有的资源,包括js
for res in resources:
print res.url, res.http_status
print ghost.content #输出内容
ghost.capture_to('/home/chenjianshu/tmp/header.png') #截图
print end-start
main()
其它功能官网上都有写,功能不多,但简单够用。性能一般,毕竟是完整浏览器,不能要求太多。page返回是None比较奇怪,得有空看下源码。
转载于:https://blog.51cto.com/jianshusoft/1315870