做影视网站引流,湖北响应式网站建设费用,企业网站设计费用,腾讯企业邮箱登录入口下载1,谷歌浏览器默认位置 2#xff0c;ChromeDriverManager 下载的驱动位置 其中admin为机器的用户名 def installDriver(self):判断是否需要下载driver找到本机谷歌浏览器版本C:\P…1,谷歌浏览器默认位置 2ChromeDriverManager 下载的驱动位置 其中admin为机器的用户名 def installDriver(self):判断是否需要下载driver找到本机谷歌浏览器版本C:\Program Files\Google\Chrome\Application\122.0.6261.112 找到名字为版本号的文件夹dirPathrC:\Program Files\Google\Chrome\Applicationversion122.0.6261.112for item in os.listdir(dirPath):if re.search(r\d{3}.\d.\d{4}.\d{3},item):versionre.search(r\d{3}.\d.\d{4}.\d{3},item).group(0)breakusername getpass.getuser() #获取本机driver_path fC:\\Users\\{username}\\.wdm\\drivers\\chromedriver\\win64\\{version}\\chromedriver-win32\\chromedriver.exeif not os.path.exists(driver_path):driver_path ChromeDriverManager().install()return driver_pathdef createDriver(self):driver_pathself.installDriver()op webdriver.ChromeOptions()# op.add_argument(headless)op.add_argument(disable-infobars)op.add_argument(--ignore-certificate-errors)op.add_argument(--allow-insecure-localhost)op.add_argument(-ignore -ssl-errors)op.add_experimental_option(excludeSwitches, [enable-automation]) # 以键值对的形式加入参数prefs {profile.default_content_settings.popups: 1}op.add_experimental_option(prefs, prefs)script Object.defineProperty(navigator, webdriver, {get: () undefined})self.driver webdriver.Chrome(serviceService(driver_path))self.driver.maximize_window()self.driver.execute_cdp_cmd(Page.addScriptToEvaluateOnNewDocument, {source: script})self.driver.execute_script(script)script Object.defineProperty(navigator, plugins, {get: () 2})self.driver.execute_cdp_cmd(Page.addScriptToEvaluateOnNewDocument, {source: script})self.driver.set_page_load_timeout(60)