from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
driver = webdriver.Chrome("D:/chromedriver")
products=[] #List to store name of the product
prices=[] #List to store price of the product
Descriptions=[] #List to store rating of the product
driver.get("https://www.nike.com/w/womens-lifestyle-shoes-13jrmz5e1x6zy7ok")
content = driver.page_source
soup = BeautifulSoup(content)
for a in soup.find_all('a',href=True, attrs={'class':'product-card__link-overlay'}):
name = a.find('div', attrs={'class':'product-card__title'})
price=a.find('div', attrs={'class':'product-card__price'})
products.append(name.text)
prices.append(price.text)
Descriptions=a.find('li', attrs={'class':'product-card__subtitle'})
#ratings.append(rating.text)
df = pd.DataFrame({'Product Name':products,'Price':prices, 'Description' :Descriptions})
#,'Rating':ratings
df.to_csv('scraping .csv', index=False, encoding='utf-8')
AttributeError Traceback (most recent call last)
<ipython-input-38-5c26eac7db21> in <module>
6 price=a.find('div', attrs={'class':'product-card__price'})
7 #rating=a.find('div', attrs={'class':'_3LWZlK'})
----> 8 products.append(name.text)
9 prices.append(price.text)
10 Decsriptions=a.find('li', attrs={'class':'product-card__subtitle'})
AttributeError: 'NoneType' object has no attribute 'text'