How can I get the contents of an Amazon shopping cart?
Asked Answered
H

2

13

I've been investigating whether it's possible to get a list of the saved items in my Amazon shopping basket programmatically.

Their Product Advertising API has methods for getting wishlists described here and working with remote shopping carts described here.

But the shopping cart of items stored while on the Amazon web site is treated as a local shopping cart, and therefore is not accessible through the Product Advertising API.

According to the last link:

The opposite of a remote shopping cart is a local shopping cart, which is the shopping cart customers use while shopping on www.amazon.com. It is considered local because Amazon hosts the shopping web pages as well as the shopping cart. Product Advertising API operations work solely with remote shopping carts.

Has anyone found a way of getting the contents of the "local" cart, apart from scraping the HTML?

Hyperesthesia answered 1/4, 2010 at 14:1 Comment(1)
AFAIK, there are no public APIs offered by Amazon that support any kind of authentication against your "shopping" account. Hence you cannot access shopping carts or private wishlists through supported APIs.Sextans
I
2

I know this is a 10 year old question, but here is a way to do it using python3.

import browser_cookie3
import requests

cookies = browser_cookie3.chrome(domain_name='.amazon.com')
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36'
}

with requests.session() as s:
    s.cookies = cookies
    s.headers = headers
    url = 'https://www.amazon.com/gp/cart/view.html?ref_=nav_cart'

    resp = s.get(url)
    print('resp text contains shopping cart data')

You can use something like BeautifulSoup to parse response text. In order for this to work the user must be signed into Amazon in Chrome. browser_cookie3 can be set to use other browsers as well.

Impetuous answered 2/2, 2021 at 23:53 Comment(0)
A
0

It appears that Amazon does not offer this in their API. However, depending on what your environment is it may be possible to do this without using the API by having the user sign in and doing a page scrape of the shopping cart page.

This link may be useful: http://bililite.com/blog/2010/10/31/hacking-my-way-to-an-amazon-wishlist-widget/

Ambrogino answered 7/5, 2014 at 17:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.