I've tried variations of the code below but cant seem to grab the SKU numbers. The length of the all_elements list is 60 which is perfect (because this is 1/60 on the page), but when I try and print it out it's blank.
all_elements = driver.find_elements_by_xpath('//div[@class="item-list__meta"]')
numele = len(all_elements)
for i in range(numele):
print(all_elements[i].text)
<div class="item-list__more-content">
<div class="item-list__meta">
SKU: 55404407<br>
Stores with stock: 76%<br>
Stores with discount: 100% </div>
<div class="item-list__actions">
如果只需要SKU行,则可以尝试使用该定位器:
//div[@class="item-list__meta"]/br[1]/preceding-sibling::text()
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.