Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions simple_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ def get_products_info(self, links):
asins = self.get_asins(links)
products = []
for asin in asins:
product = self.get_single_product_info(asin)
if product:
if product := self.get_single_product_info(asin):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AmazonAPI.get_products_info refactored with the following changes:

products.append(product)
return products

Expand All @@ -120,14 +119,14 @@ def get_single_product_info(self, asin):
seller = self.get_seller()
price = self.get_price()
if title and seller and price:
product_info = {
return {
'asin': asin,
'url': product_short_url,
'title': title,
'seller': seller,
'price': price
'price': price,
}
return product_info

Comment on lines -123 to +129
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AmazonAPI.get_single_product_info refactored with the following changes:

return None

def get_title(self):
Expand Down Expand Up @@ -173,7 +172,7 @@ def get_asin(product_link):
return product_link[product_link.find('/dp/') + 4:product_link.find('/ref')]

def shorten_url(self, asin):
return self.base_url + 'dp/' + asin
return f'{self.base_url}dp/{asin}'
Comment on lines -176 to +175
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AmazonAPI.shorten_url refactored with the following changes:


def convert_price(self, price):
price = price.split(self.currency)[1]
Expand Down