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

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐