我正在尝试抓取丝芙兰的网站,但我无法获得我想要的信息,我正在尝试提取每种香水的名称,我尝试了两种方法,使用“brand=soup.find(..... )[...]" 并将其从循环中取出,然后返回“sku_item_brand”,这不是我想要的,第二种方法是下面的代码,但我不知道为什么它在环形。我收到的错误是“NoneType”对象不可下标有人请帮忙!
from bs4 import BeautifulSoup
import requests
source = requests.get('https://www.sephora.com/shop/perfume')
soup = BeautifulSoup(source.content, 'html.parser')
perfume_containers = soup.find_all('div', class_="css-12egk0t")
# List to store the scraped data in
brands = []
for container in perfume_containers:
# The brand
brand = container.find('span', class_='css-ktoumz')['data-at']
brands.append(brand)
相关分类