Skip to content Skip to sidebar Skip to footer

Wait For A Delay Before Capture Website Image With PyQt

I'm working with PyQt (as a Python beginner). I need to be able to take screenshots of a website on a headless system. I was using PhantomJS earlier for another project, but they d

Solution 1:

I recommend using selenium. It is made for doing web automation, screenshots, and testing. Because it uses firefox it is very easy to have full flash support. It can also be run in a headless mode. The code below works at taking a screenshot of a web page with flash like the youtube video you had. You can see the screenshot it took below. A few things to keep in mind. selenium has a save_screenshot method which you can see is commented out in the code. I didn't use it because it wasn't taking proper screenshot of flash components, you can correct this by using the technique in Taking screenshot of flash object using Selenium with Webdriver. I chose though to just take a screenshot of the screen using the imagemagic import command. This is a screenshot tool that works in Linux. You can check out Take a screenshot via a python script. [Linux] and Get screenshot on Windows with Python? for other approaches of taking screenshots.

code

import time, selenium.webdriver, subprocess
browser = selenium.webdriver.Firefox()
browser.get('http://www.youtube.com/watch?v=bFEoMO0pc7k')
time.sleep(6)
#browser.save_screenshot('test.png')
subprocess.check_output('import -window root screen.png', shell=True)
browser.quit()

screenshot

enter image description here


Post a Comment for "Wait For A Delay Before Capture Website Image With PyQt"