Developer_hong

스크린샷 저장 Chrome, Firefox 본문

프로그래밍/Python

스크린샷 저장 Chrome, Firefox

Developer_hong 2020. 10. 22. 14:36
반응형

# FireFox

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
ff_driver = None
# Setting ff_profile
ff_profile = webdriver.FirefoxProfile()
ff_profile.set_preference("general.useragent.override", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36")

# Setting ff_options
ff_options = Options()
ff_options.add_argument("--headless")
# ff_options.add_argument( "--screenshot test.jpg http://google.com/" )

ff_url = "https://getemoji.com/"
ff_driver = webdriver.Firefox(firefox_profile=ff_profile,options=ff_options)
ff_driver.set_window_size(1000,30000)
ff_driver.get(ff_url)
ff_driver.save_screenshot('/Users/Desktop/ff_test/firefox_screen_test.png')
ff_driver.quit()


 

# Google Chrome
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('window-size=1000x30000')
options.add_argument("user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36")
options.add_argument("disable-gpu")
options.add_argument('--no-sandbox')
driver = webdriver.Chrome('/Users/Desktop/ff_test/chromedriver',options=options)
url = "https://getemoji.com/"
driver.get(url)
driver.save_screenshot("/Users/Desktop/ff_test/chrome_screen_test.png")

반응형

'프로그래밍 > Python' 카테고리의 다른 글

Python - Mac Terminal  (0) 2020.07.10
Python IDE  (0) 2020.07.10