如何使用亚马逊 MWS 从卖家 ID 获取卖家名称 API
How to get seller name from Seller Id using Amazon MWS API
我通过 http://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_NotificationType.html 收到了 PriceChangedNotification。
它 returns 每个 ASIN 的新报价的卖家 ID。
我需要通过卖家 ID 获取卖家名称。
我该怎么做?
我们所做的是获取卖家 ID 列表并使用 URL 进行抓取,如下所示:https://www.amazon.com/sp?seller=xxxxxxxxxxx 用于每个卖家 ID。然后从结果 html 中提取卖家名称(查找 id=sellerName)并将其存储在 table 中。然后,当我收到 PriceChangedNotification 时,我会加入我的卖家 table 以生成我的报告,或者我可能需要的任何其他内容。
Keepa 有一个不错的 API 可以为您提供这个以及 MWS 不会提供的许多其他东西。它不是免费的,但如果您想从亚马逊获得一堆东西并且不想自己抓取所有东西,那么这可能是值得的。不幸的是,MWS 似乎越来越严格。
https://keepa.com/#!discuss/t/request-seller-information/790?u=keepa
兔子洞把我带到了这里。考虑到我花了一个小时谷歌搜索和测试,所以下一个可能会节省一些时间。
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
seller_id = ""
s = requests.Session()
url = f"https://www.amazon.co.uk/sp?seller={seller_id}"
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0',
"Cookie":'i18n-prefs=GBP;' # won't work without this cookie
}
r = s.get(url, headers=headers)
# >> print(r) --> response 200
soup = BeautifulSoup(r.text, "html.parser")
soup.find("h1", {"id": "sellerName"}).text
需要注意的重要事项:Amazon 阻止爬虫,您需要模拟 http 请求。使用邮递员 ping 您感兴趣的特定 URL 并查看它发送的内容 headers,特别是它发送的 cookie。在这种情况下,如果没有 i18n-prefs cookie,我的请求将无法工作。
我通过 http://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_NotificationType.html 收到了 PriceChangedNotification。
它 returns 每个 ASIN 的新报价的卖家 ID。
我需要通过卖家 ID 获取卖家名称。
我该怎么做?
我们所做的是获取卖家 ID 列表并使用 URL 进行抓取,如下所示:https://www.amazon.com/sp?seller=xxxxxxxxxxx 用于每个卖家 ID。然后从结果 html 中提取卖家名称(查找 id=sellerName)并将其存储在 table 中。然后,当我收到 PriceChangedNotification 时,我会加入我的卖家 table 以生成我的报告,或者我可能需要的任何其他内容。
Keepa 有一个不错的 API 可以为您提供这个以及 MWS 不会提供的许多其他东西。它不是免费的,但如果您想从亚马逊获得一堆东西并且不想自己抓取所有东西,那么这可能是值得的。不幸的是,MWS 似乎越来越严格。
https://keepa.com/#!discuss/t/request-seller-information/790?u=keepa
兔子洞把我带到了这里。考虑到我花了一个小时谷歌搜索和测试,所以下一个可能会节省一些时间。
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
seller_id = ""
s = requests.Session()
url = f"https://www.amazon.co.uk/sp?seller={seller_id}"
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0',
"Cookie":'i18n-prefs=GBP;' # won't work without this cookie
}
r = s.get(url, headers=headers)
# >> print(r) --> response 200
soup = BeautifulSoup(r.text, "html.parser")
soup.find("h1", {"id": "sellerName"}).text
需要注意的重要事项:Amazon 阻止爬虫,您需要模拟 http 请求。使用邮递员 ping 您感兴趣的特定 URL 并查看它发送的内容 headers,特别是它发送的 cookie。在这种情况下,如果没有 i18n-prefs cookie,我的请求将无法工作。