How To Extract Info Within A #shadow-root (open) Using Selenium Python?
I got the next url related to an online store https://www.tiendasjumbo.co/buscar?q=mani and I can't extract the product label an another fields: from selenium import webdriver impo
Solution 1:
The products within the website https://www.tiendasjumbo.co/buscar?q=mani are located within a #shadow-root (open)
.
Solution
To extract the product label you have to use shadowRoot.querySelector()
and you can use the following Locator Strategy:
Code Block:
driver.get('https://www.tiendasjumbo.co/buscar?q=mani') item = driver.execute_script("return document.querySelector('impulse-search').shadowRoot.querySelector('div.group-name-brand h1.impulse-title span.formatted-text')") print(item.text)
Console Output:
La especial mezcla de nueces, maní, almendras y marañones x 450 g
References
You can find a couple of relevant discussions in:
Baca Juga
- Pyqt5 Cannot Update Progress Bar From Thread And Received The Error "cannot Create Children For A Parent That Is In A Different Thread"
- How To Pass The Value In Search On Url Https://www.virustotal.com/gui/home/search Using Selenium And Python
- Can't Locate Elments Within Shadow-root (open) Using Python Selenium
Post a Comment for "How To Extract Info Within A #shadow-root (open) Using Selenium Python?"