selenium+chromedriver

chromweb driverchromedriver.exe):
http://npm.taobao.org/mirrors/chromedriver/

firefoxweb driver (geckodriver.exe)
https://github.com/mozilla/geckodriver/releases

Click to enter and find the windows version. Note: The windows version is only 32-bit, not 64-bit

Python gets its own exe path

New script test.py
 

import sys
print(sys.executable)

import sys
print(sys.executable) 

Execution output: E:\virtualenv\django3\Scripts\python.exe

 Here, it is the python.exe path.

 Put the chromedriver.exe file in the path where python.exe is located.

test:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 
# Set selenium to use chrome's headless mode
chrome_options = Options()
# Add configuration when starting the browser
browser = webdriver.Chrome(options=chrome_options)
# Open Baidu
browser .get('https://www.baidu.com/')
# Wait for loading, up to 20 seconds
browser.implicitly_wait(20) 

Guess you like

Origin blog.csdn.net/qq_38767359/article/details/123241305