1

Hi i want to scrape all options from page https://mike.larsson.pl/pl/ (you have to log in :/ free account) witch has got few drop down lists with relevant values.

There is a form with few drop down list for example Type,Brand,Model,Engine etc The problem is that when you select one value from first dropdown the rest is changing their values options For example when you choose Brand Honda in model dropdown you have CBR125, CBR600 When you choose brand kawasaki in model dropdown you have only kawasaki models

And i would like to get only correct pairs of it But insted i get all cross join values( becouse propobly my code is not reloading the form )

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
url = "https://www.larsson.pl/index.html"
url2 = 'https://www.larsson.pl/przejdz-do-MIKE.html'
rll = r'C:\Users\damian.kulisz\Desktop\arc\python\New folder\Lib\site-packages\selenium\webdriver\firefox'
driver = webdriver.Firefox(rll)
driver.get(url)
username = driver.find_element_by_id("username")
password = driver.find_element_by_id("password")

username.send_keys("xxxx@xx.xx")
password.send_keys("xxxx")

driver.find_element_by_id("formSignIn").submit()
driver.get(url2)

dropdown_menu = Select(driver.find_element_by_id('type'))
for option in dropdown_menu.options:
     if option.text =='Trajka':
         dropdown_menu2 = Select(driver.find_element_by_id('Marke'))
         for option2 in dropdown_menu2.options:
             dropdown_menu3 = Select(driver.find_element_by_id('Verkaufsbezeichnung'))
             for option3 in dropdown_menu3.options:
                 print(f'{option.text},{option2.text},{option3.text}')```
ou_ryperd
  • 2,037
  • 2
  • 18
  • 23
guzikmen
  • 11
  • 2
  • Possible duplicate of [How to select an option from a dynamic dropdown using Selenium?](https://stackoverflow.com/questions/51222724/how-to-select-an-option-from-a-dynamic-dropdown-using-selenium) – Niloct Jun 11 '19 at 12:41
  • hi no it is not that case. in case of your link user whant to have only one option and i want to scrap all possibility pairs of options And i don't know how to do it – guzikmen Jun 12 '19 at 06:25
  • You just have to apply the method in the other answer for each option you want to fetch. The selenium code will click, wait, and then you scrape the option value. – Niloct Jun 12 '19 at 12:07
  • what in case when i have 1000 options? – guzikmen Jun 12 '19 at 12:20
  • In your case I would say that for each model option you'll need a wait. I haven't created an account there anyway. The idea is that for every possible batch of options that are loaded dynamically, you have to trigger the load with a click to parent option, and then you wait, and then scrape the HTML. – Niloct Jun 12 '19 at 12:28

0 Answers0