@@ -282,35 +282,234 @@ def parse_product(item):
282282 except Exception :
283283 pass
284284
285- # Parse Offers Listings data
286- product .prices = Class ()
285+ # Trade In
286+ product .trade_in = Class ()
287+ try :
288+ product .trade_in .elegible = item .item_info .trade_in_info .is_eligible_for_trade_in
289+ except Exception :
290+ product .trade_in .elegible = None
291+ try :
292+ product .trade_in .price = item .item_info .trade_in_info .price .amount
293+ except Exception :
294+ product .trade_in .price = None
295+ try :
296+ product .trade_in .currency = item .item_info .trade_in_info .price .currency
297+ except Exception :
298+ product .trade_in .currency = None
299+
300+ # Prices
287301 try :
288302 listings = item .offers .listings [0 ]
289303 except Exception :
290304 listings = None
305+ product .prices = Class ()
306+ product .prices .price = Class ()
291307 try :
292- product .prices .availability = listings .availability . message
308+ product .prices .price . value = listings .price . amount
293309 except Exception :
294- product .prices .availability = None
310+ product .prices .price . value = None
295311 try :
296- product .prices .price = listings .price .amount
312+ product .prices .price . currency = listings .price .currency
297313 except Exception :
298- product .prices .price = None
314+ product .prices .price . currency = None
299315 try :
300- product .prices .pvp = listings .saving_basis . amount
316+ product .prices .price . per_unit = listings .price . price_per_unit
301317 except Exception :
302- product .prices .pvp = None
318+ product .prices .price . per_unit = None
303319 try :
304- product .prices .currency = listings .price .currency
320+ product .prices .price . display = listings .price .display_amount
305321 except Exception :
306- product .prices .currency = None
307-
308- # Parse Offers Summaries data
309- product .offers = Class ()
322+ product .prices .price .display = None
323+ product .prices .price .savings = Class ()
324+ try :
325+ product .prices .price .savings .value = listings .price .savings .amount
326+ except Exception :
327+ product .prices .price .savings .value = None
328+ try :
329+ product .prices .price .savings .currency = listings .price .savings .currency
330+ except Exception :
331+ product .prices .price .savings .currency = None
332+ try :
333+ product .prices .price .savings .per_unit = listings .price .savings .price_per_unit
334+ except Exception :
335+ product .prices .price .savings .per_unit = None
336+ try :
337+ product .prices .price .savings .display = listings .price .savings .display_amount
338+ except Exception :
339+ product .prices .price .savings .display = None
340+ try :
341+ product .prices .price .savings .percentage = listings .price .savings .percentage
342+ except Exception :
343+ product .prices .price .savings .percentage = None
344+ product .prices .pvp = Class ()
345+ try :
346+ product .prices .pvp .value = listings .saving_basis .amount
347+ except Exception :
348+ product .prices .pvp .value = None
349+ try :
350+ product .prices .pvp .currency = listings .saving_basis .currency
351+ except Exception :
352+ product .prices .pvp .currency = None
353+ try :
354+ product .prices .pvp .per_unit = listings .saving_basis .price_per_unit
355+ except Exception :
356+ product .prices .pvp .per_unit = None
357+ try :
358+ product .prices .pvp .display = listings .saving_basis .display_amount
359+ except Exception :
360+ product .prices .pvp .display = None
361+ product .prices .availability = Class ()
362+ try :
363+ product .prices .availability .message = listings .availability .message
364+ except Exception :
365+ product .prices .availability .message = None
366+ try :
367+ product .prices .availability .type = listings .availability .type
368+ except Exception :
369+ product .prices .availability .type = None
370+ try :
371+ product .prices .availability .max_order_quantity = listings .availability .max_order_quantity
372+ except Exception :
373+ product .prices .availability .max_order_quantity = None
374+ try :
375+ product .prices .availability .min_order_quantity = listings .availability .min_order_quantity
376+ except Exception :
377+ product .prices .availability .min_order_quantity = None
378+ product .prices .condition = Class ()
379+ try :
380+ product .prices .condition .condition = listings .condition .value
381+ except Exception :
382+ product .prices .condition = None
383+ try :
384+ product .prices .condition .condition_display = listings .condition .display_value
385+ except Exception :
386+ product .prices .condition_display = None
387+ try :
388+ product .prices .condition .sub_condition = listings .condition .sub_condition .value
389+ except Exception :
390+ product .prices .sub_condition = None
391+ try :
392+ product .prices .condition .sub_condition_display = listings .condition .sub_condition .display_value
393+ except Exception :
394+ product .prices .sub_condition_display = None
395+ product .prices .merchant = Class ()
396+ try :
397+ product .prices .merchant .default_shipping_country = listings .merchant_info .default_shipping_country
398+ except Exception :
399+ product .prices .merchant .default_shipping_country = None
400+ try :
401+ product .prices .merchant .merchant_id = listings .merchant_info .id
402+ except Exception :
403+ product .prices .merchant .merchant_id = None
404+ try :
405+ product .prices .merchant .name = listings .merchant_info .name
406+ except Exception :
407+ product .prices .merchant .name = None
408+ product .prices .other = Class ()
409+ try :
410+ product .prices .other .buybox_winner = listings .is_buy_box_winner
411+ except Exception :
412+ product .prices .other .buybox_winner = None
413+ try :
414+ product .prices .other .loyalty_points = listings .loyalty_points
415+ except Exception :
416+ product .prices .other .loyalty_points = None
417+ try :
418+ product .prices .other .amazon_fulfilled = listings .delivery_info .is_amazon_fulfilled
419+ except Exception :
420+ product .prices .other .amazon_fulfilled = None
421+ try :
422+ product .prices .other .free_shipping_elegible = listings .delivery_info .is_free_shipping_eligible
423+ except Exception :
424+ product .prices .other .free_shipping_elegible = None
425+ try :
426+ product .prices .other .prime_elegible = listings .delivery_info .is_prime_eligible
427+ except Exception :
428+ product .prices .other .prime_elegible = None
429+ try :
430+ product .prices .other .prime_exclusive = listings .program_eligibility .is_prime_exclusive
431+ except Exception :
432+ product .prices .other .prime_exclusive = None
433+ try :
434+ product .prices .other .prime_pantry = listings .program_eligibility .is_prime_pantry
435+ except Exception :
436+ product .prices .other .prime_pantry = None
437+ try :
438+ product .prices .other .violates_map = listings .violates_map
439+ except Exception :
440+ product .prices .other .violates_map = None
310441 try :
311- product .offers = item . offers . summaries
442+ product .prices . other . offer_id = listings . id
312443 except Exception :
313- product .offers = None
444+ product .prices .other .offer_id = None
445+
446+
447+ # Offers Summary
448+ try :
449+ summaries = item .offers .summaries
450+ product .offers_summary = []
451+ except Exception :
452+ summaries = None
453+ product .offers_summary = None
454+ if summaries :
455+ for x in summaries :
456+ offer = Class ()
457+ offer .highest_price = Class ()
458+ offer .lowest_price = Class ()
459+ try :
460+ offer .highest_price .value = x .highest_price .amount
461+ except Exception :
462+ offer .highest_price .value = None
463+ try :
464+ offer .highest_price .currency = x .highest_price .currency
465+ except Exception :
466+ offer .highest_price .currency = None
467+ try :
468+ offer .highest_price .per_unit = x .highest_price .price_per_unit
469+ except Exception :
470+ offer .highest_price .per_unit = None
471+ try :
472+ offer .highest_price .display = x .highest_price .display_amount
473+ except Exception :
474+ offer .highest_price .display = None
475+ try :
476+ offer .lowest_price .value = x .lowest_price .amount
477+ except Exception :
478+ offer .lowest_price .value = None
479+ try :
480+ offer .lowest_price .currency = x .lowest_price .currency
481+ except Exception :
482+ offer .lowest_price .currency = None
483+ try :
484+ offer .lowest_price .per_unit = x .lowest_price .price_per_unit
485+ except Exception :
486+ offer .lowest_price .per_unit = None
487+ try :
488+ offer .lowest_price .display = x .lowest_price .display_amount
489+ except Exception :
490+ offer .lowest_price .display = None
491+ offer .condition = Class ()
492+ try :
493+ offer .condition .condition = x .condition .value
494+ except Exception :
495+ offer .condition .condition = None
496+ try :
497+ offer .condition .condition .condition_display = x .condition .display_value
498+ except Exception :
499+ offer .condition .condition_display = None
500+ try :
501+ offer .condition .condition .sub_condition = x .condition .sub_condition .value
502+ except Exception :
503+ offer .condition .sub_condition = None
504+ try :
505+ offer .condition .condition .sub_condition_display = x .condition .sub_condition .display_value
506+ except Exception :
507+ offer .condition .sub_condition_display = None
508+ try :
509+ offer .offer_count = x .offer_count
510+ except Exception :
511+ offer .offer_count = None
512+ product .offers_summary .append (offer )
314513
315514 return product
316515
@@ -336,7 +535,7 @@ def __init__(self, key, secret, tag, country, throttling=0.9):
336535 self .marketplace = 'www.amazon.' + DOMAINS [country ]
337536 self .last_query_time = time .time ()
338537
339- def get_product (self , product_id , condition = Condition .NEW ):
538+ def get_product (self , product_id , condition = Condition .ANY ):
340539 """Find product information for a specific product on Amazon.
341540
342541 Args:
0 commit comments