为了账号安全,请及时绑定邮箱和手机立即绑定

pandas groupby 对象,组合和绘图

pandas groupby 对象,组合和绘图

回首忆惘然 2023-06-13 17:17:19
切换到 iFrame 时出现错误AttributeError: 'WebDriver' 对象没有属性 'driver'这个错误的解决方案是什么?我不确定为什么...driver = webdriver.Firefox()url = ''driver.get(url)while True:    iframe = driver.find_element_by_xpath('//iframe[@src="/pages/mediator-search"]')    driver.driver.switch_to.frame(iframe)    WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH, '//a[@class="mediator-name"]')))        response = Selector(text=driver.page_source)    agents = response.xpath('//a[@class="mediator-name"]')    for agent in agents:        outFile =  open("data.csv",'a+',newline="",encoding='utf-8')        writer = csv.writer(outFile)        link = agent.xpath('.//@href').get()        vals = [link]        writer.writerow(vals)        outFile.close()        try:        next_page = driver.find_element_by_xpath('//a[contains(text(), "›")]')        if next_page:            next_page.click()    except:        break还需要进行以下导入from selenium import webdriverfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.common.exceptions import TimeoutExceptionfrom selenium.webdriver.support.ui import Selectfrom selenium.webdriver.common.action_chains import ActionChainsfrom selenium.webdriver.common.keys import Keys
查看完整描述

1 回答

?
富国沪深

TA贡献1790条经验 获得超9个赞

driver.driver.switch_to.frame(iframe)- 在这里更正.. :)。它应该是driver.switch_to.frame(iframe)



查看完整回答
反对 回复 2023-06-13
  • 1 回答
  • 0 关注
  • 146 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信