立即学习:https://edu.csdn.net/course/play/24756/284650?utm_source=blogtoedu
from selenium import webdriver
driver=webdriver.Chrome(executable_path="C:\Program Files\Google\Chrome\Application\chromedriver.exe")
driver.get("https://www.baidu.com/")
driver.implicity_wait(2)
driver.execute_script("window.open('https://www.douban.com/')")
driver.switch_to.window(self.driver.window_handles[1]) #切换到豆瓣页面
print(driver.page_source) #打印豆瓣源代码,如果不切换页面,将打印百度页面源代码。