```python
from selenium import webdriver
from selenium.webdriver.common.by import By #导入选择器
from selenium.webdriver.chrome.options import Options #导入配置项
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.support.ui import WebDriverWait #导入显示等待
from selenium.webdriver.support import expected_conditions as EC #导入期望条件
def config_of_browser():
options = Options()
options.add_argument("--disable-blink-features=AutomationControlled")
#关闭浏览器的自动化控制
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
#保持浏览器打开
options.add_experimental_option('detach', True)
browser = webdriver.Chrome()
return browser
if __name__ == '__main__':
driver = config_of_browser()
#请求目标url
driver.get("https://accounts.douban.com/passport/login")
driver.implicitly_wait(10)
driver.find_element(By.CLASS_NAME, 'account-tab-account').click()
#输入账号密码, 并登录
driver.find_element(By.ID, 'username').send_keys("19312562437")
driver.find_element(By.ID, 'password').send_keys("hhz.KONGJIAN")
driver.find_element(By.XPATH, '//*[@id="account"]/div[2]/div[2]/div/div[2]/div[1]/div[4]/a').click()
try:
# 切换框架
driver.switch_to.frame("tcaptcha_iframe_dy")
slide_bg = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "slideBg")))
# 获取滑块图像链接
s = slide_bg.get_attribute('style')
print(s)
except Exception as e:
print("发生错误:", e)
```