I am scrapping this page (Joybuy) with Selenium and Beautifulsoup
I want to get the cost of shipping to certain countries.
The problem that I can make Selenium open the dialog and click on the shipping countries list but I can't make it click on certain countries, here is my code.
#libraries imported before the code
path_to_firefox = '/var/py/web_scraping/geckodriver'
browser = webdriver.Firefox(executable_path = path_to_firefox)
browser.get('https://www.joybuy.com/1178507.html?isActivitying=false')
elem = browser.find_element_by_class_name('sdc-prompt')
elem.click()
elem2 = browser.find_element_by_class_name('j-country-sel')
elem2.click()
How can I then go through this list and choose?
Try the below code. It should fix the errors. Lets consider we would like to select the country Brazil
:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('https://www.joybuy.com/1178507.html?isActivitying=false')
browser.find_element_by_class_name('sdc-prompt').click()
browser.find_element_by_css_selector(".select.j-country-sel").click()
browser.find_element_by_css_selector(".pop-ship .fn-ovs [name='Brazil']").click() #select any country by changing the name
browser.quit()
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.