1

I wrote a program to take a screenshoot of a chosen webpage. User types an url and then my application takes a screenshoot of typed page. I wonder is it possible (and how) to hide a browser window? I mean, no to open it but take a screenshoot? thanks in advance :)

I use python 2.7 and splinter for this. Code below:

from splinter import Browser
import socket
url = raw_input('> ')
browser = None 
try:
 browser = Browser('firefox')
 try:
 browser.visit(url)
 if browser.status_code.is_success():
 browser.driver.save_screenshot('picture.png')
 except socket.gaierror, e:
 print "URL not found: %s" % url
finally:
 if browser is not None:
 browser.quit()

For Ubuntu, I found this: Selenium-Python Client Library - Automating in Background but how about Windows?

asked Mar 17, 2013 at 14:48
1

1 Answer 1

2

You have a few options:

  1. Use a "dumb" headless browser, like mechanize. This is fast, and perfect for a quick visit and a screenshot. However, it doesn't understand javascript.

  2. Use the zope.testbrowser browser in your splinter tests. It's a headless browser, so it won't appear on screen. It understands javascript, but will take more investment to get up and going.

  3. Just use urllib2 with some special headers.

answered May 20, 2013 at 14:35

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.