Skip to content

Commit c697cb6

Browse files
Flipkart Mattressess script file and Output
1 parent 8b065c9 commit c697cb6

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

Flipkart mattresses.xlsx

154 KB
Binary file not shown.

flipkart Mattresses.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
from selenium import webdriver
3+
from openpyxl import Workbook
4+
5+
wb = Workbook()
6+
ws = wb.active
7+
l = 2
8+
ws.cell(row=1, column=1).value = "Product Name"
9+
ws.cell(row=1, column=2).value = "Price"
10+
ws.cell(row=1, column=3).value = "Size"
11+
ws.cell(row=1, column=4).value = "Rating"
12+
ws.cell(row=1, column=5).value = "Image Link"
13+
ws.cell(row=1, column=6).value = "Product Link"
14+
driver = webdriver.Chrome(executable_path="E:\\driver\\chromedriver.exe")
15+
16+
for r in range(1, 25):
17+
print(r)
18+
driver.get(url="https://www.flipkart.com/furniture/mattresses/pr?sid=wwe%2Crg9&otracker=nmenu_sub_Home+%26"
19+
"+Furniture_0_Mattresses&page=" + str(r))
20+
for container in driver.find_elements_by_class_name("_4ddWXP"):
21+
for title in container.find_elements_by_class_name("s1Q9rs"):
22+
title.get_attribute('title')
23+
ws.cell(row=l,column=1).value = title.get_attribute('title')
24+
print("Product Name:", title.get_attribute('title'))
25+
for price in container.find_elements_by_class_name("_30jeq3"):
26+
print("Price", price.text)
27+
ws.cell(row=l,column=2).value = price.text
28+
for size in container.find_elements_by_class_name("_3Djpdu"):
29+
print("Size:", size.text)
30+
ws.cell(row=l,column=3).value = size.text
31+
for rating in container.find_elements_by_class_name("_2D5lwg"):
32+
print("Rating:", rating.text)
33+
ws.cell(row=l,column=4).value = rating.text
34+
for hyper_link in container.find_elements_by_class_name("_3exPp9"):
35+
link = hyper_link.get_attribute('src')
36+
print("Image Link",hyper_link.get_attribute('src'))
37+
ws.cell(row=l,column=5).value = link
38+
for hyper in container.find_elements_by_class_name("_2rpwqI"):
39+
link = hyper.get_attribute('href')
40+
print("Product Link",link)
41+
ws.cell(row=l,column=6).value = link
42+
l= l+1
43+
#
44+
#
45+
wb.save("Flipkart mattresses.xlsx")
46+
47+
driver.quit()

0 commit comments

Comments
 (0)