| Line 43... |
Line 43... |
| 43 |
input_json = json.loads(self.response_data)
|
43 |
input_json = json.loads(self.response_data)
|
| 44 |
offerPrice = float(input_json['offer_price'])
|
44 |
offerPrice = float(input_json['offer_price'])
|
| 45 |
cod = int(input_json['pay_type_supported'].get('COD'))
|
45 |
cod = int(input_json['pay_type_supported'].get('COD'))
|
| 46 |
offerUrl = (input_json['offer_url'])
|
46 |
offerUrl = (input_json['offer_url'])
|
| 47 |
inStock = (input_json['instock'])
|
47 |
inStock = (input_json['instock'])
|
| - |
|
48 |
shareUrl = input_json['shareurl']
|
| 48 |
return {'offerPrice':offerPrice,'codAvailable':cod,'offerUrl':offerUrl,'inStock':inStock}
|
49 |
return {'offerPrice':offerPrice,'codAvailable':cod,'offerUrl':offerUrl,'inStock':inStock, 'shareUrl':shareUrl}
|
| 49 |
except:
|
50 |
except:
|
| 50 |
return {'offerPrice':0.0,'codAvailable':0,'offerUrl':"",'inStock':False}
|
51 |
return {'offerPrice':0.0,'codAvailable':0,'offerUrl':"",'inStock':False,'shareUrl':None}
|
| 51 |
|
52 |
|
| 52 |
if __name__ == '__main__':
|
53 |
if __name__ == '__main__':
|
| 53 |
scraper = PaytmScraper()
|
54 |
scraper = PaytmScraper()
|
| 54 |
print scraper.read('https://catalog.paytm.com/v1/mobile/product/1849504')
|
55 |
scraper.read('https://catalog.paytm.com/v1/mobile/product/25735648')
|
| - |
|
56 |
|