Python 在多个类中进行刮削

Python 在多个类中进行刮削,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我试图使用selenium webdriver在class=“a-size-based-plus a-color-base”中提取以下HTML中的文本 我的代码结构如下: from selenium import webdriver from selenium.webdriver import Chrome from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys fr

我试图使用selenium webdriver在
class=“a-size-based-plus a-color-base”
中提取以下HTML中的文本

我的代码结构如下:

from selenium import webdriver
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.expected_conditions import presence_of_element_located

import os
import re  # regular expressions, are imported from python directly
import time
import numpy as np
import pandas as pd
from difflib import SequenceMatcher
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
-----下面是一些不相关的代码-----


除了代码之外的最后一次尝试是最重要的。

通过查看HTML,我在您的定位器中看到一个输入错误,这一行:

brand = element.find_element_by_css_selector('.a-size-based-plus.a-color-base')
它应该是
size base
而不是
size-based
,请尝试以下操作:

brand = element.find_element_by_css_selector('.a-size-base-plus.a-color-base')

希望,这有帮助。

通过查看HTML,我在您的定位器中看到一个输入错误,这行:

brand = element.find_element_by_css_selector('.a-size-based-plus.a-color-base')
它应该是
size base
而不是
size-based
,请尝试以下操作:

brand = element.find_element_by_css_selector('.a-size-base-plus.a-color-base')

希望,这会有帮助。

你还没有说你面临的问题/错误。你还没有说你面临的问题/错误。哈哈,谢谢@DebanjanB:)我希望这就是问题。它成功了!!我也做了一点修改
brand=element。通过“css”选择器('.a-size-base-plus.a-color-base')查找“element”。text
Haha,谢谢@DebanjanB:)我希望这就是问题所在。它成功了!!我也做了一点修改
brand=element。通过“css”选择器('.a-size-base-plus.a-color-base')查找“element”。text