如何获取亚马逊购物车的内容?

发布于 2024-08-27 08:44:35 字数 658 浏览 5 评论 0原文

我一直在研究是否可以以编程方式获取我的亚马逊购物篮中已保存商品的列表。

他们的产品广告 API 具有获取愿望清单的方法,如下所述此处 并使用描述的远程购物车这里

但是,存储在亚马逊网站上的商品的购物车被视为本地购物车,因此无法通过产品广告 API 访问。

根据最后一个链接:

与远程购物车相反的是本地购物车,即客户在 www.amazon.com 上购物时使用的购物车。它被认为是本地的,因为亚马逊托管购物网页和购物车。产品广告 API 操作仅适用于远程购物车。

除了抓取 HTML 之外,是否有人找到了获取“本地”购物车内容的方法?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无声情话 2024-09-03 08:44:35

我知道这是一个 10 年前的问题,但这里有一种使用 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')

您可以使用 BeautifulSoup 之类的工具来解析响应文本。为了使其正常工作,用户必须在 Chrome 中登录 Amazon。 browser_cookie3 也可以设置为使用其他浏览器。

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.

似梦非梦 2024-09-03 08:44:35

亚马逊似乎没有在其 API 中提供此功能。但是,根据您的环境,可能可以在不使用 API 的情况下通过让用户登录并执行购物车页面的页面抓取来完成此操作。

此链接可能有用: http://bililite.com/blog/2010/10/31/hacking-my-way-to-an-amazon-wishlist-widget/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文