用selenium刮网

用selenium刮网,第1张

用selenium刮网

结果是在一个iframe -切换到它,然后得到

.page_source

iframe = driver.find_element_by_css_selector("#mainContent iframe")driver.switch_to.frame(iframe)

我还要添加一个等待表加载的方法:

from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECwait = WebDriverWait(driver, 10)# locate and switch to the iframeiframe = driver.find_element_by_css_selector("#mainContent iframe")driver.switch_to.frame(iframe)# wait for the table to loadwait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.companyName')))print(driver.page_source)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5600338.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存