简体   繁体   中英

Click button on web page (python, webscraping)

I have a problem with clicking the button while scraping. For example on the web page https://kolesa.kz/a/show/95457776 there is a button to show phone number (" Контакты продавца "), just on the right side of +7 777

I tried using method.click() of bs4 and I used div class of this button (" offer__show-phone action-link showPhonesLink js__show-phones "). But every time I got error that there is no such class name.

Maybe you know other methods of it?

Thank you in advance!

The issue occurs where you're trying to locate an element using multiple classes, this causes selenium to throw back an error, the below will locate and click the button:

from selenium import webdriver

driver = webdriver.Firefox(executable_path = 'path_to_webdriver')
driver.get('https://kolesa.kz/a/show/95457776')

element = driver.find_element_by_class_name('showPhonesLink')

element.click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM