gpt4 book ai didi

python - Geckodriver 错误 : "FirefoxWebElement has no len()"

转载 作者:太空宇宙 更新时间:2023-11-04 10:00:48 24 4
gpt4 key购买 nike

我安装了 geckodriver,因为 selenium 不再与最新版本的 Firefox 兼容。请注意,我在 Mac 上使用 Spyder。之前,我成功地从一个网站上抓取了数据,但是一旦我切换到 geckodriver,我就不得不对脚本进行修改。例如,

 browser.find_by_id('closeMessageButton').click() 

现在

 browser.find_element_by_id('closeMessageButton').click() 

我修改了以下内容:

prov_count = len(browser.find_by_id("j_id48:j_id49:j_id108:cmbSecimCevresi").first.find_by_tag('option'))-1

到:

prov_count = len(browser.find_element_by_id("j_id48:j_id49:j_id108:cmbSecimCevresi").find_element_by_tag_name('option'))-1

但我收到以下错误:“TypeError:‘FirefoxWebElement’类型的对象没有 len()”

我正在尝试获取以下网站上的列表计数,因此我可以遍历“*Il adi”下的列表:https://sonuc.ysk.gov.tr/module/sspsHalkoylamasiYeni.jsf

最佳答案

您需要 .find_elements_by_tag_name()...复数形式(注意“elements”中的“s”)。您使用的单数版本将只返回一个元素并且没有长度 (len)。

关于python - Geckodriver 错误 : "FirefoxWebElement has no len()",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43712014/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com