From fd58018ea1d822ff8b43e370628d359cf55c1abb Mon Sep 17 00:00:00 2001 From: leonghui <6092315+leonghui@users.noreply.github.com> Date: Sat, 20 Jan 2024 00:05:09 +0000 Subject: [PATCH] Simplify queries for the dimension endpoint --- amazon_feed.py | 9 ++------- amazon_feed_data.py | 16 ---------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/amazon_feed.py b/amazon_feed.py index 515fa22..51b34fe 100644 --- a/amazon_feed.py +++ b/amazon_feed.py @@ -305,19 +305,14 @@ def get_search_results(search_query): def get_dimension_url(listing_query, item_id): # Call the "dimension" endpoint which is used on mobile pages # to display price and availability for product variants - # - # Use a pair of ASINs with a valid parent-child relationship - # to trigger a response locale_data = listing_query.locale base_url = "https://" + locale_data.domain dimension_endpoint = base_url + "/gp/twister/dimension?" query_dict = { - "asinList": locale_data.child_asin + "," + item_id, - "productTypeDefinition": None, - "productGroupId": locale_data.product_group, - "parentAsin": locale_data.parent_asin, + "asinList": item_id, + "parentAsin": item_id, } return dimension_endpoint + urlencode(query_dict) diff --git a/amazon_feed_data.py b/amazon_feed_data.py index eb54094..411aaa9 100644 --- a/amazon_feed_data.py +++ b/amazon_feed_data.py @@ -19,42 +19,29 @@ class AmazonLocale: domain: str unavailable_text: UnavailabilityText option_pattern: OptionPatterns - child_asin: str - parent_asin: str - product_group: str def __hash__(self): return hash(self.code) -# requires valid child_asin, parent_asin, and product_group for item dimension endpoint locale_list = [ AmazonLocale( "AU", "www.amazon.com.au", UnavailabilityText.EN, OptionPatterns.EN, - "B08N3J8GTX", - "B0BCMPYWKN", - "amazon_ereaders_display_on_website", ), AmazonLocale( "SG", "www.amazon.sg", UnavailabilityText.EN, OptionPatterns.EN, - "B09SWTG9GF", - "B0BCSYDF82", - "amazon_devices_display_on_website", ), AmazonLocale( "UK", "www.amazon.co.uk", UnavailabilityText.EN, OptionPatterns.EN, - "B08N36XNTT", - "B0BF6HS47P", - "amazon_ereaders_display_on_website", ), ] @@ -63,9 +50,6 @@ def __hash__(self): "www.amazon.com", UnavailabilityText.EN, OptionPatterns.EN, - "B09TMK7QFX", - "B0BCTGXVB2", - "amazon_ereaders_display_on_website", ) locale_list.append(default_locale)