#导入模块
from selenium import webdriver
from selenium.webdriver.common.by import By
driver=webdriver.Chrome()#实例化浏览器对象
driver.get('https://music.163.com/')#打开网易云
#进入嵌套页面,(网页源代码相当于父亲,嵌套网页相当于儿子)
driver.switch_to.frame(0)#方法一:通过索引进入(可能有多个嵌套网页)
#Method 2: Locate the nested page first, then jump to it
iframe=driver.find_element(By.ID,'g_iframe')
driver.switch_to.frame(iframe)
#从嵌套网页中出来(进入父嵌套网页)
driver.switch_to.parent_frame()#(父嵌套网页)
Because when some websites enter the next interface, they find that the next interface and the previous interface have the same parts. For simplicity, website developers encapsulate this part with modules, that is, nested web pages.
Click on the second popular recommendation to enter
the original link: https://zhuanlan.zhihu.com/p/615365819