I have This code for get screenshot of website with python .
import time
from PIL import Image
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.headless = True
driver = webdriver.Chrome(options=options)
driver.set_window_size(1920, 1080)
URL = "https://google.com"
driver.get(URL)
time.sleep(5)
el = driver.save_screenshot('1.png')
driver.quit()
im = Image.open( "1.png")
width, height = im.size
left = 1
top = height / 7
right = 1920
bottom = 1 * height
im1 = im.crop((left, top, right, bottom))
im1 = im1.save("1.png")
it works with Centos 7 command line ( python3 main.py ) and get screenshot of page .
but when i run shell_exec("python3 main.py");
in php , do proccess until line 6 driver = webdriver.Chrome(options=options)
and line 6 does not work .
i search a lot and did'nt found any solution .
please help me with that code .
CodePudding user response:
I just solve my problem with this option :
options.add_argument("--crash-dumps-dir=/tmp")