Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

python - Cant click button with selenium

I was making a webscraper with selenium and bs4 to keep some shopping items' stock in track, there is a load more button I want to click which looks like this button and here is the HTML code for it, the website is https://www.nvidia.com/en-us/shop/geforce/?page=1&limit=9&locale=en-us

HTML code of the button

HTML code of the button

Whenever I try to find the element with bs4 it works but it never works with

driver.find_element_by_class_name("buy-link load-more-btn")

and I need it to click the button, can someone help me out

Am I was passing too many classes at once?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

find_element_by_class_name accepts only one class. You are passing multiple classes in it.

Try implementing it with one class only

driver.find_element_by_class_name("load-more-btn").click()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...