1. Video display - open 5 more Baidu pages
Directory Structure
Just put your own Google Drive in the current directory: How to download Google Drive, please refer to the blog: Please click me
provide the code
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_driver = "./chromedriver.exe"
driver = webdriver.Chrome()
for i in range(5):
js = 'window.open();'
driver.execute_script(js)
cls = driver.window_handles
driver.switch_to.window(cls[i])
driver.get("http://www.baidu.com")
time.sleep(0.1)
注意!!
For python3.8 and above, please modify:
chrome_options = Options()
chrome_options.add_experimental_option('debuggerAddress', '127.0.0.1:9222')
chrome_driver = './chromedriver.exe'
service = Service(chrome_driver)
driver = webdriver.Chrome(service=service, options=chrome_options)
I hope it can be helpful to everyone. If there is any mistake, please correct me.
A little programmer dedicated to office automation
Hope to get [a free follow] from everyone! grateful