爬虫:AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_id‘

1. 问题:

        在学习爬虫中的selenium部分时,出现AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_id’问题。

2.原因:

        由于版本迭代,新版的selenium已经不再使用find_element_by_id方法。

3. 解决办法:

        将button = browser.find_element_by_id(‘su’)修改为如下语句,

button = browser.find_element(By.ID,'su')

        再在其代码页的最前端添加下列代码,

from selenium.webdriver.common.by import By

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年8月8日
下一篇 2023年8月8日

相关推荐