设置selenium自动化Chrome浏览器的图片不加载 2就是不加载
options = webdriver.ChromeOptions()
prefs = {
'profile.default_content_setting_values': {
'images': 2,
}
}
options.add_experimental_option('prefs', prefs)
设置无界面浏览器
options.add_argument('--headless')
最大化浏览器
browser.maximize_window()
为selenium添加cookie
browser.add_cookie(
字典类型的参数,
例子:
'name': c['name'],
'value': c['value'],
'path': '/',
'expires': None
)
讲浏览器拉倒底部
browser.execute_script(
'window.scrollTo(0,document.body.scrollHeight)'
)
显式等待
wait = WebDriverWait(self.browser, timeout=10)
wait.until(
EC.presence_of_element_located((By.XPATH, 'XPATH代码'))
)