偶尔要用到,start writing

实现步骤

  1. 先启动 Chrome,打开任务管理器,找到 chrome.exe,地址栏输入 cmd,然后执行 chrome.exe --remote-debugging-port=12345

img.png

  1. 看 !!! 12345 端口开了没 netstat -aon | findstr "12345"

img_2.png

img_3.png

  1. 开了,你就连呗 ~ 开始指挥你的浏览器 ~~~ 往左走,往右走
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

if __name__ == '__main__':
    chrome_options = Options()
    chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:12345")
    driver = webdriver.Chrome(options=chrome_options)
    driver.get("https://www.selenium.dev/")
    print(driver.title)
    driver.quit()

img_4.png


Talk is cheap, show me huajianketang's code. 😄


华健课堂
1 声望0 粉丝