Beispiel #1
0
 def get_price_from_listing(self, listing):
     try:
         return float(dsearch(listing, 'LandedPrice')[0]['Amount']['value'])
     except ValueError:
         return dsearch(listing, 'LandedPrice')[0]['Amount']['value']
     except (KeyError, IndexError):
         return None
Beispiel #2
0
 def get_price_from_listing(self, listing):
     try:
         return float(dsearch(listing, 'LandedPrice')[0]['Amount']['value'])
     except ValueError:
         return dsearch(listing, 'LandedPrice')[0]['Amount']['value']
     except (KeyError, IndexError):
         return None
Beispiel #3
0
 def get_offerings_from_product(self, product):
     offerings = dsearch(product, 'LowestOfferListing')
     try:
         if isinstance(offerings[0], list):
             return offerings[0]
         else:
             return offerings
     except IndexError as e:
         raise KeyError('Offerrings not found.')
Beispiel #4
0
 def get_offerings_from_product(self, product):
     offerings = dsearch(product, 'LowestOfferListing')
     try:
         if isinstance(offerings[0], list):
             return offerings[0]
         else:
             return offerings
     except IndexError as e:
         raise KeyError('Offerrings not found.')
Beispiel #5
0
 def get_seller_from_listing(self, listing):
     try:
         return dsearch(listing, 'FulfillmentChannel')[0]['value']
     except (KeyError, IndexError):
         return None
Beispiel #6
0
 def get_asin_from_product(self, product):
     try:
         return dsearch(product, 'ASIN')[0]['value']
     except IndexError as e:
         raise KeyError("ASIN doesn't exist")
Beispiel #7
0
 def get_products_from_response(self):
     if isinstance(self.response, dict):
         return [dsearch(self.response, 'Product')]
     else:
         return [dsearch(item, 'Product') for item in self.response]
Beispiel #8
0
 def get_seller_from_listing(self, listing):
     try:
         return dsearch(listing, 'FulfillmentChannel')[0]['value']
     except (KeyError, IndexError):
         return None
Beispiel #9
0
 def get_asin_from_product(self, product):
     try:
         return dsearch(product, 'ASIN')[0]['value']
     except IndexError as e:
         raise KeyError("ASIN doesn't exist")
Beispiel #10
0
 def get_products_from_response(self):
     if isinstance(self.response, dict):
         return [dsearch(self.response, 'Product')]
     else:
         return [dsearch(item, 'Product') for item in self.response]