-
Notifications
You must be signed in to change notification settings - Fork 2
/
scrapper.py
40 lines (28 loc) · 868 Bytes
/
scrapper.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
34
35
36
37
38
39
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 19 18:42:55 2017
@author: Ayush Vatsyayan
"""
from product_crawler import ProductCrawler
from product_retriever import ProductRetriever
import time
import pandas as pd
products = ProductCrawler().get_products()
retriever = ProductRetriever()
# get detail of each product
available_prds = []
for product in products:
prd_id = product['id']
details = retriever.get_product_details(prd_id)
if details['stockAvailability'].lower() != 'out of stock':
print('-----')
print(product)
print(details)
available_prds.append(product)
else:
print('skipping:',product['name'])
time.sleep(1)
df = pd.DataFrame(available_prds)
df = df[['id','name','discounted_price','non_discounted_price']]
df.to_csv('tmp.csv', index=False)