mirror of
https://github.com/vimagick/dockerfiles.git
synced 2025-12-21 21:33:02 +01:00
update selenium
This commit is contained in:
@@ -38,7 +38,7 @@ baidu-search.py
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
from selenium import webdriver
|
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.proxy import Proxy, ProxyType
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
@@ -50,20 +50,20 @@ proxy = Proxy({
|
|||||||
'sslProxy': '1.2.3.4:8080',
|
'sslProxy': '1.2.3.4:8080',
|
||||||
})
|
})
|
||||||
|
|
||||||
capabilities = DesiredCapabilities.CHROME
|
options = Options()
|
||||||
proxy.add_to_capabilities(capabilities)
|
options.set_capability('proxy', proxy.to_capabilities())
|
||||||
|
|
||||||
driver = webdriver.Remote(
|
driver = webdriver.Remote(
|
||||||
command_executor='http://127.0.0.1:4444/wd/hub',
|
command_executor='http://127.0.0.1:4444/wd/hub',
|
||||||
desired_capabilities=capabilities
|
options=options
|
||||||
)
|
)
|
||||||
|
|
||||||
driver.get('http://www.baidu.com/')
|
driver.get('http://www.baidu.com/')
|
||||||
driver.find_element_by_id('kw').send_keys('ip')
|
driver.find_element(By.ID, 'kw').send_keys('ip')
|
||||||
driver.find_element_by_id('su').click()
|
driver.find_element(By.ID, 'su').click()
|
||||||
|
|
||||||
WebDriverWait(driver, 10).until(
|
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')
|
driver.save_screenshot('baidu.png')
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
video:
|
video:
|
||||||
image: selenium/video:ffmpeg-4.3.1-20231020
|
image: selenium/video:ffmpeg-6.1-20240402
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/videos
|
- ./data:/videos
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in New Issue
Block a user