Estoy intentando scrapear una lista de webs. Iba scrapeando bien y devolviendo los datos hasta que apareció el error:
Message: unknown error: DevToolsActivePort file doesn't exist
Encontré una solución y mi código quedó asi:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
for i in datos:
#browser = webdriver.Chrome('chromedriver.exe')
chrome_options = Options()
chromeOptions.add_experimental_option("prefs", {"profile.managed_default_content_settings.images": 2})
chromeOptions.add_argument("--no-sandbox")
chromeOptions.add_argument("--disable-setuid-sandbox")
chromeOptions.add_argument("--remote-debugging-port=9222") # this
chromeOptions.add_argument("--disable-dev-shm-using")
chromeOptions.add_argument("--disable-extensions")
chromeOptions.add_argument("--disable-gpu")
chromeOptions.add_argument("start-maximized")
chromeOptions.add_argument("disable-infobars")
chromeOptions.add_argument(r"user-data-dir=.\cookies\\test")
b= webdriver.Chrome(chrome_options=chromeOptions)
wait = WebDriverWait(b, 10)
browser.get(i)
b = webdriver.Chrome(chrome_options=chromeOptions)
b.quit()
Pero recibo el error
Error: name 'chromeOptions' is not defined
Alguna idea de como solucionarlo?
chrome_options = Options() chromeOptions.add_experimental_option
. chromeOptions no existe :)