Skip to content

Commit e2ccc09

Browse files
committed
added price
1 parent 0dac942 commit e2ccc09

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

amazonscraper/client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ def _get_products(self, keywords="", search_url="", max_product_nb=100):
260260
product_dict['asin'] = asin
261261

262262
if "slredirect" not in proper_url: # slredirect = bad url
263+
# Get price using asin
264+
info_url = urljoin(
265+
self.base_url,
266+
f"gp/cart/desktop/ajax-mini-detail.html/ref=added_item_1?ie=UTF8&asin={asin}")
267+
info = self._get(info_url)
268+
soup_info = BeautifulSoup(info.text, _DEFAULT_BEAUTIFULSOUP_PARSER)
269+
price = soup_info.select('span.a-size-medium.a-color-price.sc-price')
270+
product_dict['price'] = price[0].getText()
271+
263272
self.product_dict_list.append(product_dict)
264273

265274
if len(self.product_dict_list) < max_product_nb:
@@ -301,5 +310,3 @@ def _get_high_res_img_url(img_url):
301310
"""
302311
high_res_url = img_url.split("._")[0] + ".jpg"
303312
return high_res_url
304-
305-

0 commit comments

Comments
 (0)