1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-25 00:08:49 +00:00

update selenium

This commit is contained in:
kevin 2024-04-15 16:51:21 +08:00
parent 6215fe7016
commit 1a6a87191b
2 changed files with 8 additions and 8 deletions

@ -38,7 +38,7 @@ baidu-search.py
```python
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
@ -50,20 +50,20 @@ proxy = Proxy({
'sslProxy': '1.2.3.4:8080',
})
capabilities = DesiredCapabilities.CHROME
proxy.add_to_capabilities(capabilities)
options = Options()
options.set_capability('proxy', proxy.to_capabilities())
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=capabilities
options=options
)
driver.get('http://www.baidu.com/')
driver.find_element_by_id('kw').send_keys('ip')
driver.find_element_by_id('su').click()
driver.find_element(By.ID, 'kw').send_keys('ip')
driver.find_element(By.ID, 'su').click()
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, 'nums_text'))
EC.presence_of_element_located((By.ID, 'content_left'))
)
driver.save_screenshot('baidu.png')

@ -40,7 +40,7 @@ services:
restart: unless-stopped
video:
image: selenium/video:ffmpeg-4.3.1-20231020
image: selenium/video:ffmpeg-6.1-20240402
volumes:
- ./data:/videos
ports: