Home > Software engineering >  Ikea(SG) store stock status
Ikea(SG) store stock status

Time:09-27

This is using Python, Selenium and chromedriver. Novice learner and came across this situation:

how do I scrape from a pop up window?

Using this example url: https://www.ikea.com/sg/en/p/knapper-standing-mirror-white-80396243/ (There is no elements on stock status on this page)

On the right hand pane there is "Check in-store stock". On click, a pop window will show store name, location and stock status (In stock, Out of stock). I can see all the elements.

How can I scrape store name and stock status in this situation?

CodePudding user response:

I assume you have succeeded in bringing up the pop window by click Check in-store stock.

In selenium you can find multiple elements by method .find_elements_*, in this case using by class name.

It's simple, you can pair the name and stock info using the zip function to extract the text elements in parallel:

#click 'Check in-store stock', perform here

#add a wait here

names = driver.find_elements_by_class_name('range-revamp-change-store__store-info')
stocks = driver.find_elements_by_class_name('range-revamp-stockcheck__store-text')

for name, stock in zip(names, stocks):
    print(name.text)
    print(stock.text)
  • Related