I installed geckodriver since selenium is no longer compatible with recent versions of Firefox. Please note that I am using Spyder on a Mac. Before, I had successfully scraped data from a website, but once I switched to geckodriver, I had to make modifications to the script. For example,
browser.find_by_id('closeMessageButton').click()
is now
browser.find_element_by_id('closeMessageButton').click()
I modified the following:
prov_count = len(browser.find_by_id("j_id48:j_id49:j_id108:cmbSecimCevresi").first.find_by_tag('option'))-1
to:
prov_count = len(browser.find_element_by_id("j_id48:j_id49:j_id108:cmbSecimCevresi").find_element_by_tag_name('option'))-1
but I get the following error: "TypeError: object of type 'FirefoxWebElement' has no len()"
I am trying to get the count of the list on the following website and so I can loop through the list under "*Il adi": https://sonuc.ysk.gov.tr/module/sspsHalkoylamasiYeni.jsf
You want .find_elements_by_tag_name()
... the plural version (notice the "s" in "elements"). The singular version you are using will only return one element and does not have a length (len
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With