def estabilish_driver(self): """ Creates chromedriver instance with arguments. If used inside Docker, specify env variable: SCRAPPER_ENV=DOCKER to inject additional arguments to driver for stability. """ chrome_options = webdriver.ChromeOptions() chrome_options.add_argument(f'--log-path={LOG_PATH}/chromedriver.log') if os.environ.get('SCRAPPER_ENV', '') == 'DOCKER': for arg in DOCKER_ARGS: chrome_options.add_argument(f'--{arg}') return webdriver.Chrome(chrome_options=chrome_options)
import selenium import webdriver import pandas as pd import time # settings options = webdriver.ChromeOptions() options.add_argument('--headeless') options.add_argument('--disable-gpu') options.add_argument('--lang=ja') browser = webdriver.Chrome(chrome_options=options, excecutable_path='./chromedriver') df = pd.DataFrame(columns=['name', 'address', 'location0', 'location1', 'location2'])