Python爬虫:Selenium获取iframe里面的内容

如下:

driver.get(url)
iframe = driver.find_elements_by_tag_name('iframe')[0]
driver.switch_to.frame(iframe)
soup = BeautifulSoup(driver.page_source, "lxml")
# soup 就是iframe所嵌入页面的内容了

你可能感兴趣的:(Python/爬虫,Selenium,iframe,switch_to,BeautifulSoup,python爬虫)