偶爾要用到,start writing
實現步驟
- 先啓動
Chrome,打開任務管理器,找到chrome.exe,地址欄輸入cmd,然後執行chrome.exe --remote-debugging-port=12345
- 看 !!!
12345端口開了沒netstat -aon | findstr "12345"
- 開了,你就連唄 ~ 開始指揮你的瀏覽器 ~~~ 往左走,往右走
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()
Talk is cheap, show me huajianketang's code. 😄