- Download what you need chrome drive , Place a directory , Create chromedriver Use , For example, I put it in C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe
- Then enter chrome Under the folder ( Right click chrome browser , Open the folder ),shift+ Right click to open the command line , Run the following :
chrome.exe --remote-debugging-port=9527 --user-data-dir=“D:\pycharm\zdh_rxy"
--remote-debugging-port Remote control interface
--user-data-dir For project directory
You can log in to the website you want to log in , Subsequently, you can directly control the opened web page .
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time
import watch
options = Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9527")
# chromedriver The directory where the driver is located
chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"
s = Service(chromedriver)
browser = webdriver.Chrome(service=s, options=options)
while(True):
( Control code snippet ...)