首页 > 解决方案 > 使用python刮取在线商店的产品颜色

问题描述

因此,我正在搜索一家在线商店,并且在购买具有多种颜色的商品时遇到了麻烦,因为每种颜色的可用尺寸和价格都在变化,因此我需要单击每种颜色并为其提取数据。

我的问题是单击存储在列表中的每种提取颜色

colors_available = []
color_main = soup.find('li', {'class': 'facet-color-options selected'})['title']
colors_available.append(color_main)
color_remain = soup.find_all('li', {'class': 'facet-color-options deselected'})
if color_remain:
    for color in color_remain:
        colors_available.append(color['title']) # collecting all available colors
        # hover(color.find('input')['name'])
        # select('COLOR', color)
        click(color['title']) # click on color 
        time.sleep(3)
        print(f'color CLICKED is: {color}') # confirm on color clicked
    print(f"Colors: {colors_available}") # print full str list of available colors

注意:还在链接上使用“选择”和“悬停”然后单击它没有用,给出以下错误:

LookupError

希望它被充分解释,并且你能尽快支持它,因为它激怒了我一段时间

标签: pythonweb-scrapingautomationbuild-automation

解决方案


推荐阅读