Python Selenium无法获取alt-src属性



我无法访问所有产品的img src。图像src属性值返回"无";对于某些元素。我注意到图像元素有时没有指定alt,因此元素可能看起来像这样:

<img alt src="imagesource.jpg">

这似乎造成了解析src属性的问题。有变通办法吗?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
webdriver.DesiredCapabilities.CHROME['acceptSslCerts']=True
# Routing if using Chrome driver
driver = webdriver.Chrome()
categories = [
"sleeping+bags",
"sleeping+pads",
"carabiners"
]
for category in categories:

driver.get(f'https://www.backcountry.com/Store/catalog/search.jsp?s=u&q={category}')
def get_products():
products = driver.find_elements_by_class_name('product')
for product in products:
brand = product.find_element_by_class_name('ui-pl-name-brand').text
model = product.find_element_by_class_name('ui-pl-name-title').text
image = product.find_element_by_class_name('ui-pl-img').find_element_by_tag_name('img').get_attribute('src')
print({ "category": category, "page": page, "brand": brand, "model": model, "image": image})
# BEGIN EXECUTION:
page = 1
get_products()
loop = True
while loop:
try:
next_page = driver.find_element_by_link_text('Next Page')
next_page.click()
time.sleep(3)
page += 1
get_products()
except:
loop = False

您的问题是,当您尝试获取src属性时,图像没有加载,因此它确实是空的。您可以通过在获取src之前使元素可见WebDriverWait来解决此问题。这是我使用的代码:

image = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.ui-pl-img img'))).get_attribute('src')

您需要添加导入:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

所以你的整个代码可能看起来像这样:

from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
webdriver.DesiredCapabilities.CHROME['acceptSslCerts']=True
# Routing if using Chrome driver
driver = webdriver.Chrome()
categories = [
"sleeping+bags",
"sleeping+pads",
"carabiners"
]
wait = WebDriverWait(driver, 10)
for category in categories:
driver.get(f'https://www.backcountry.com/Store/catalog/search.jsp?s=u&q={category}')
def get_products():
products = driver.find_elements_by_class_name('product')
for product in products:
brand = product.find_element_by_class_name('ui-pl-name-brand').text
model = product.find_element_by_class_name('ui-pl-name-title').text
image = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.ui-pl-img img'))).get_attribute('src')
print({ "category": category, "page": page, "brand": brand, "model": model, "image": image})
# BEGIN EXECUTION:
page = 1
get_products()
loop = True
while loop:
try:
next_page = driver.find_element_by_link_text('Next Page')
next_page.click()
time.sleep(3)
page += 1
get_products()
except:
loop = False

我得到的输出是这样的:

{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': "Cat'S Meow Sleeping Bag: 20F Synthetic", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': 'Wasatch Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': 'Eco Trail Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Coleman', 'model': 'Kompact Sleeping Bag: 40 Degree Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': 'Eco Trail Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': 'Trestles 15 Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': 'Dolomite One Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Rab', 'model': "Solar 3 Synthetic Sleeping Bag - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Kelty', 'model': "Cosmic 20 Sleeping Bag: 20F Down - Men'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': "Trestles 15 Sleeping Bag: 15F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': "Lamina Sleeping Bag: 30F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': 'Lamina Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': 'Eco Trail Sleeping Bag: 20F Down', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': "Lamina Sleeping Bag: 0F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': "Trestles 30 Sleeping Bag: 30F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Coleman', 'model': 'Kompact Sleeping Bag: 25 Degree Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': 'Wasatch Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': 'NanoWave 25 Sleeping Bag: 25F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'ALPS Mountaineering', 'model': 'Blue Springs Sleeping Bag: 35F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Kelty', 'model': "Mistral Sleeping Bag: 20F Synthetic - Kids'", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': 'Lamina Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': 'Trestles 0 Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': 'Lamina Eco AF Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'ALPS Mountaineering', 'model': 'Double Wide Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'ALPS Mountaineering', 'model': 'Crescent Lake Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'NEMO Equipment Inc.', 'model': "Tempo 20 Sleeping Bag: 20F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': 'Bozeman 15 Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': "Lamina Sleeping Bag: 15F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': 'Never Summer Sleeping Bag: 0F Down', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Stoic', 'model': 'Groundwork Single Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Rab', 'model': 'Solar 4 Synthetic Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': 'Lamina Sleeping Bag: -20 Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'NEMO Equipment Inc.', 'model': 'Jazz Duo Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Kelty', 'model': "Callisto 30 Sleeping Bag: 30F Synthetic - Kids'", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Kelty', 'model': 'Cosmic Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'The North Face', 'model': 'Eco Trail Sleeping Bag: 0F Down', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Kelty', 'model': "Mistral Sleeping Bag: 30F Synthetic - Kids'", 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': 'Trestles 30 Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'ALPS Mountaineering', 'model': 'Crescent Lake Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Marmot', 'model': 'NanoWave 55 Sleeping Bag: 55F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Mountain Hardwear', 'model': 'Bozeman 0 Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 1, 'brand': 'Big Agnes', 'model': 'Lost Dog Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/TNF/TNF03ZE/BLWITEGR.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': 'Lamina Eco AF Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': 'Rook Sleeping Bag: 0F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'The North Face', 'model': 'Blue Kazoo Sleeping Bag: 15F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Kelty', 'model': "Cosmic 20 Sleeping Bag: 20F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Kelty', 'model': "Cosmic 20 Sleeping Bag: 20F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Big Agnes', 'model': "Sidewinder SL Sleeping Bag: 35F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Therm-a-Rest', 'model': 'Saros Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'The North Face', 'model': 'Gold Kazoo Down Sleeping Bag: 35F', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'The North Face', 'model': 'Eco Trail Sleeping Bag: 55F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': 'Ultra Elite 30 Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': "Rook Sleeping Bag: 0F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Rab', 'model': "Solar 2 Synthetic Sleeping Bag - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'NEMO Equipment Inc.', 'model': 'Sonic -20 Sleeping Bag: -20F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': 'NanoWave 45 Sleeping Bag: 45F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': 'Ultra Elite 20 Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': 'Phantom GORE-TEX Sleeping Bag: -40F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Big Agnes', 'model': 'Lost Dog Sleeping Bag: 45F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Rab', 'model': 'Neutrino 800 Sleeping Bag: -5F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Therm-a-Rest', 'model': 'Saros Sleeping Bag: 32F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Kelty', 'model': 'Cosmic Sleeping Bag: 40F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'The North Face', 'model': 'Eco Trail Sleeping Bag: 35F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': "Bishop Pass Sleeping Bag: 0F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Big Agnes', 'model': 'Lost Dog Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Kelty', 'model': "Tuck Sleeping Bag: 20F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'The North Face', 'model': 'Inferno Sleeping Bag: -20F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'ALPS Mountaineering', 'model': 'Razor Fleece Sleeping Bag/Liner', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': 'Trestles Elite Eco 0 Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Big Agnes', 'model': 'Lost Dog Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': "Bozeman Sleeping Bag: 15F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': "Bozeman Sleeping Bag: 30F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': 'Warmcube Expedition Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Therm-a-Rest', 'model': 'Parsec Sleeping Bag: 20F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': 'Micron 40 Sleeping Bag: 40F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': "Banzai Trestles 35 Sleeping Bag: 35F Synthetic - Kids'", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Sea To Summit', 'model': '100% Premium Silk Sleeping Bag Liner', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'The North Face', 'model': 'Inferno Sleeping Bag: -40F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'ALPS Mountaineering', 'model': 'Cosmic Quilt', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Marmot', 'model': "Teton Sleeping Bag: 15F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Rab', 'model': 'Solar 2 Synthetic Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountainsmith', 'model': 'Redcloud Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'The North Face', 'model': 'Green Kazoo Sleeping Bag: 0F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 2, 'brand': 'Mountain Hardwear', 'model': "Rook Sleeping Bag: 15F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHWZ9G9/UND.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Marmot', 'model': 'Yolla Bolly Doublewide 30 Sleeping Bag: 30 Degree Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Mountain Hardwear', 'model': "Rook Sleeping Bag: 15F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Western Mountaineering', 'model': 'UltraLite Sleeping Bag: 20F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'The North Face', 'model': 'The One Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Big Agnes', 'model': 'Buell Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Mountain Hardwear', 'model': 'Rook Sleeping Bag: 30F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Marmot', 'model': "Trestles 30 Sleeping Bag: 30F Synthetic - Kids'", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'NEMO Equipment Inc.', 'model': "Forte 20 Sleeping Bag: 20F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Marmot', 'model': 'Micron 50 Sleeping Bag: 50F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Marmot', 'model': 'Never Winter Sleeping Bag: 30F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Mountain Hardwear', 'model': 'Lamina Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Morrison Outdoors', 'model': "Big Mo 20 Sleeping Bag - Toddlers'", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Big Agnes', 'model': 'Cabin Creek Double Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Big Agnes', 'model': 'Husted Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Big Agnes', 'model': 'Anvil Horn Sleeping Bag: 15F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Kelty', 'model': 'Cosmic 0 Sleeping Bag: 0F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Mountain Hardwear', 'model': 'Lamina Eco AF Sleeping Bag: 15F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Rab', 'model': 'Solar 1 Synthetic Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'NEMO Equipment Inc.', 'model': "Riff 30 Sleeping Bag: 30-Degree Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Big Agnes', 'model': 'Sleepy Bear 35 FireLine Core Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Sea To Summit', 'model': "Altitude AtI Sleeping Bag: 25F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Big Agnes', 'model': "Sunbeam Sleeping Bag: 0F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Marmot', 'model': "Angel Fire Sleeping Bag: 25F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Sea To Summit', 'model': 'Ember EbI Sleeping Bag: 40F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Mountain Hardwear', 'model': 'Phantom Sleeping Bag: 0F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Big Agnes', 'model': "Blue Lake Sleeping Bag: 25F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Rab', 'model': "Andes 800 Sleeping Bag: -8F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'NEMO Equipment Inc.', 'model': "Azura 35 Sleeping Bag: 35F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'NEMO Equipment Inc.', 'model': 'Tempo 35 Sleeping Bag: 35F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Rab', 'model': 'Ascent 500 Sleeping Bag: 24F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'NEMO Equipment Inc.', 'model': 'Forte 20 Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Mountain Hardwear', 'model': 'Bishop Pass Sleeping Bag: 15F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Klymit', 'model': 'Nest Sleeping Bag Liner', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Rab', 'model': 'Solar 3 Synthetic Sleeping Bag', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'NEMO Equipment Inc.', 'model': "Tempo 35 Sleeping Bag: 35F Synthetic - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Western Mountaineering', 'model': 'Versalite Sleeping Bag: 10F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'NEMO Equipment Inc.', 'model': 'Tempo 20 Sleeping Bag: 20F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Mountain Hardwear', 'model': 'Bozeman 30 Sleeping Bag: 30F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Marmot', 'model': 'Sawtooth Sleeping Bag: 15F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Western Mountaineering', 'model': 'Everlite Sleeping Bag: 45F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Rab', 'model': "Ascent 700 Sleeping Bag: 17F Down - Women'S", 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 3, 'brand': 'Marmot', 'model': 'Helium Sleeping Bag: 15F Down', 'image': 'https://content.backcountry.com/images/items/medium/MAR/MARZ9I7/BOGAKEGR.jpg'}
{'category': 'sleeping+bags', 'page': 4, 'brand': 'Mountain Hardwear', 'model': 'Phantom GORE-TEX Sleeping Bag: 0F Down', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHW01CT/ALPRD.jpg'}
{'category': 'sleeping+bags', 'page': 4, 'brand': 'Mountainsmith', 'model': 'Crestone Sleeping Bag: 0F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHW01CT/ALPRD.jpg'}
{'category': 'sleeping+bags', 'page': 4, 'brand': 'Big Agnes', 'model': "Wolverine Sleeping Bag: 15F Synthetic - Kids'", 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHW01CT/ALPRD.jpg'}
{'category': 'sleeping+bags', 'page': 4, 'brand': 'Big Agnes', 'model': 'V Notch UL Sleeping Bag: 40F Synthetic', 'image': 'https://content.backcountry.com/images/items/medium/MHW/MHW01CT/ALPRD.jpg'}
.....

查看这是否适用于


productResults  = driver.find_elements_by_xpath(".//div[contains(@class,'product-grid')]/div[@aria-label='Product']")
for e in productResults:
print(e.find_element_by_xpath(".//div[contains(@class,'img')]/img").get_attribute("src"))

最新更新