i am trying to get these data from the website name Flipkart.com but i am facing error i am using BeautifulSoup & selenium. i cant understand why this error is comming & i also tried many solutions available on internet.
is there any solution of i should try any other method for web scraping please help.
website is opening using selenium driver but unable to get data from the website and am not able to understand that why is this happening
here is my code which i am writing ans executing.
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
#driver = webdriver.Chrome('/usr/local/bin/chromedriver')
driver = webdriver.Chrome(executable_path='chromedriver.exe')
products=[] #List to store name of the product
prices=[] #List to store price of the product
ratings=[] #List to store rating of the product
content=driver.get("https://www.flipkart.com/mobiles/pr?sid=tyy%2C4io&p%5B%5D=facets.brand%255B%255D%3DRealme&otracker=nmenu_sub_Electronics_0_Realme")
soup = BeautifulSoup(content, 'lxml')
print(soup)
for a in soup.findAll('div', attrs={'class':'bhgxx2 col-12-12'}):
name=a.find('div', attrs={'class':'_3wU53n'})
price=a.find('div', attrs={'class':'_1vC4OE _2rQ-NK'})
rating=a.find('div', attrs={'class':'hGSR34'})
products.append(name.text)
prices.append(price.text)
ratings.append(rating.text)
print(rating.text)
df = pd.DataFrame({'Product Name':products,'Price':prices,'Rating':ratings})
print(df)
df.to_csv('products.csv', index=False, encoding='utf-8')
here is my error which i am getting from command.
Traceback (most recent call last):
File "C:\MachineLearning\WebScraping\web.py", line 10, in <module>
soup = BeautifulSoup(content, 'lxml')
File "C:\Users\karti\AppData\Local\Programs\Python\Python37-32\lib\site-packages\bs4\__init__.py", line 267, in __init__
elif len(markup) <= 256 and (
TypeError: object of type 'NoneType' has no len()
soup = BeautifulSoup(content, 'lxml')
tosoup = BeautifulSoup(content.page_source, 'lxml')