×

########### Source code for webscraping ############

from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
driver = webdriver.Chrome("/home/ranjith/Documents/Software/Chrome/chromedriver_linux64/chromedriver")
products=[] #List to store name of the product
prices=[] #List to store price of the product
driver.get("https://www.flipkart.com/laptops/~buyback-guarantee-on-laptops-/pr?sid=6bo%2Cb5g&uniq")
content = driver.page_source
soup = BeautifulSoup(content)
for a in soup.findAll('a', attrs={'class':'_31qSD5'}):
    name=a.find('div', attrs={'class':'_3wU53n'})
    price=a.find('div', attrs={'class':'_1vC4OE _2rQ-NK'})
    rating=a.find('div', attrs={'class':'hGSR34 _2beYZw'})
    try:
        products.append(name.text)
    except:
        products.append("-----")
    try:
        prices.append(price.text)
    except:
        prices.append('-----')
df = pd.DataFrame({'Product Name':products,'Price':prices}) 
print(df)

######## OUTPUT ###########

                                        Product Name    Price
0  Apple MacBook Air Core i5 5th Gen - (8 GB/128 ...  ₹67,990
1  HP 15 Core i3 6th Gen - (4 GB/1 TB HDD/Windows...  ₹28,997
2  Apple MacBook Air Core i5 5th Gen - (8 GB/256 ...  ₹92,500
3  Lenovo Core i5 7th Gen - (8 GB/1 TB HDD/DOS/2 ...  ₹52,990
4  Lenovo Core i3 6th Gen - (4 GB/1 TB HDD/Window...  ₹30,550
5  Lenovo Ideapad Core i3 6th Gen - (4 GB/1 TB HD...  ₹32,990
6  Lenovo Core i5 7th Gen - (8 GB/2 TB HDD/Window...  ₹75,500

Author

prathap7618@gmail.com

Related Posts

How to Install WSL and Ubuntu (LTS) on the Windows platform

~Sandhiya.B and Ajay This post consolidates the information needed to set up the Ubuntu terminal on a Win 11 Machine. The Ubuntu terminal...

Read out all

Ambient light sensor using a photoresistor and Arduino Uno

This project is about using a photoresistor along with an Arduino Uno board to determine the brightness of a room which is...

Read out all

Smart dustbin using Arduino

The smart dustbin is built on a microcontroller-based platform Arduino Uno board which is interfaced with the Servo motor and ultrasonic sensor....

Read out all

LOGIC GATES USING ARDUINO UNO

A basic gate is defined as a component with one or more inputs and one output.  The inputs and outputs are all...

Read out all

LAST SCHOOL STUDENTS VISIT STEMLAND

On the 14th of July students from the Last school, Auroville visited STEMLAND. The forty students accompanied by the teachers enjoyed their...

Read out all

Vim Editor Session

Vim Editor Session ~SriBhavani and Bakyalakshmi On 18th Jan 2022, we had a session on vim by HarshaVaradhan from AuraSemiconductors. In this...

Read out all