-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflipkart.py
33 lines (24 loc) · 934 Bytes
/
flipkart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from scraper import Scraper
class Flipkart(Scraper):
def get_details(self, additional=False):
product_details = self.soup.find('div', {'class': 'aMaAEs'})
self.title = self.extract_text_from_element(
product_details, 'h1', {'class': 'yhB1nd'})
self.price = self.extract_text_from_element(
product_details, 'div', {'class': '_30jeq3 _16Jk6d'}
)
self.mrp = self.extract_text_from_element(
product_details, 'div', {'class': '_3I9_wc _2p6lqe'}
)
result = {
'id': self.url.split('?')[0].split('/')[-1],
'title': self.title,
"price": self.price,
"mrp": self.mrp
}
if additional:
self.rating = self.extract_text_from_element(
self.soup, 'div', {'class': '_2d4LTz'}
)
result['rating'] = self.rating
return result