- ----------------CaptureImageJS.py----------------------------
- '''
- By Jibo He @ueseo.org
- hej...@ueseo.org
- capture web page screen under ubuntu server
- '''
- import os
- import subprocess
- xvfb ='xvfb-run'
- PHANTOM = '/home/hejibo1984/bin/phantomjs'
- APP_ROOT = '/home/hejibo1984/test'
- #APP_ROOT = os.path.dirname(os.path.realpath(__file__))
- SCRIPT = os.path.join(APP_ROOT, 'screenshot.js')
- url =''
- outfile = '/home/hejibo1984/test/ueseo.png'
- params = [xvfb,PHANTOM, SCRIPT, url, outfile]
- exitcode = subprocess.call(params)
- print exitcode
- ---------------------screenshot.js---------------------
- var page = new WebPage(),
- address, outfile, width, height, clip_height;
- address = phantom.args[0];outfile = phantom.args[1];width =
- 1024;clip_height = height = 800;
- page.viewportSize = { width: width, height: height };page.clipRect = {
- width: width, height: clip_height };
- page.open(address, function (status) {
- if (status !== 'success') {
- phantom.exit(1);
- } else {
- page.render(outfile);
- phantom.exit();
- }});
===========================================================================================
- ---------------------------截图代码 --------------------------------
- #!/usr/bin/env python
- '''
- capture the web page
-
- '''
- from selenium import webdriver
- browser = webdriver.Firefox()
- browser.get('/')
- browser.save_screenshot('ueseo.png')
- browser.close()
============================================================================================
阅读(684) | 评论(0) | 转发(0) |