是否有任何AWS API /服务可以访问亚马逊销售商品的产品评论?我有兴趣通过(ASIN,user_id)元组查找评论。我可以看到Product Advertising API返回包含URL的页面(用于嵌入IFRAME)的URL,但如果可能的话,我对审阅数据的机器可读格式感兴趣。
答案 0 :(得分:34)
更新2:
请参阅@ jpillora的评论。它可能与 Update 1 最相关。
我刚试用了产品广告API(截至2014-09-17),似乎此API只返回一个指向仅包含评论的iframe的网址。我想你必须屏幕刮擦 - 虽然我想这会打破亚马逊的TOS。
更新1:
也许。我之前写过原始答案。我现在没有时间研究这个问题,因为我不再参与关注亚马逊评论的项目了,但是他们在Product Advertising API的网页上说“产品广告API可以帮助您使用产品搜索来宣传亚马逊产品查找功能,产品信息和功能,如客户评论......“截至2011-12-08。所以我希望有人调查并发回这里;随时编辑这个答案。
<强>原始强>
不。
这是一个关于事实的讨论论坛讨论,包括为什么:http://forums.digitalpoint.com/showthread.php?t=1932326
的理论如果我错了,请发布你找到的内容。我有兴趣获取评论内容,并允许在可能的情况下向亚马逊提交评论。
您可以查看此链接:http://reviewazon.com/。我只是偶然发现它并没有调查它,但我很惊讶我在他们的网站上没有看到任何关于亚马逊产品广告API评论下降的更新:https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html
答案 1 :(得分:27)
这是关于此事的官方消息:
亲爱的产品广告API开发人员,
2010年11月8日产品评论回复组 广告API将不再返回客户评论内容和 相反,它将返回托管在其上的客户评论内容的链接 Amazon.com。您将能够在您的网站上显示客户评论 使用该链接。请参阅产品广告API开发人员 有关详细信息,请参阅此处评论回复组将 继续像以前一样运作,直到11月8日和新的链接 现在可以通过产品获得客户评论 广告API也是如此。
答案 2 :(得分:14)
这是我的快速看法 - 您可以通过更多的工作轻松地检索评论:
countries=['com','co.uk','ca','de']
books=[
'''http://www.amazon.%s/Glass-House-Climate-Millennium-ebook/dp/B005U3U69C''',
'''http://www.amazon.%s/The-Japanese-Observer-ebook/dp/B0078FMYD6''',
'''http://www.amazon.%s/Falling-Through-Water-ebook/dp/B009VJ1622''',
]
import urllib2;
for book in books:
print '-'*40
print book.split('%s/')[1]
for country in countries:
asin=book.split('/')[-1]; title=book.split('/')[3]
url='''http://www.amazon.%s/product-reviews/%s'''%(country,asin)
try: f = urllib2.urlopen(url)
except: page=""
page=f.read().lower(); print '%s=%s'%(country, page.count('member-review'))
print '-'*40
答案 3 :(得分:5)
根据亚马逊产品广告API许可协议(https://affiliate-program.amazon.com/gp/advertising/api/detail/agreement.html),特别是4.b.iii:
这意味着您禁止向您的网站展示通过其API销售产品的亚马逊产品评论。它只允许将您的网站访问者重定向到亚马逊并获得联盟佣金。
答案 4 :(得分:3)
我会使用类似上面@mfs的答案。不幸的是,他/她的回答只适用于最多10条评论,因为这是可以在一页上显示的最大值。
您可以考虑以下代码:
import requests
nreviews_re = {'com': re.compile('\d[\d,]+(?= customer review)'),
'co.uk':re.compile('\d[\d,]+(?= customer review)'),
'de': re.compile('\d[\d\.]+(?= Kundenrezens\w\w)')}
no_reviews_re = {'com': re.compile('no customer reviews'),
'co.uk':re.compile('no customer reviews'),
'de': re.compile('Noch keine Kundenrezensionen')}
def get_number_of_reviews(asin, country='com'):
url = 'http://www.amazon.{country}/product-reviews/{asin}'.format(country=country, asin=asin)
html = requests.get(url).text
try:
return int(re.compile('\D').sub('',nreviews_re[country].search(html).group(0)))
except:
if no_reviews_re[country].search(html):
return 0
else:
return None # to distinguish from 0, and handle more cases if necessary
运行1433524767(对于三个感兴趣的国家/地区的评论数量差异很大),我得到了:
>> print get_number_of_reviews('1433524767', 'com')
3185
>> print get_number_of_reviews('1433524767', 'co.uk')
378
>> print get_number_of_reviews('1433524767', 'de')
16
希望有所帮助
答案 5 :(得分:2)
很遗憾,您只能获得带有评论的iframe网址,但内容本身无法访问。
答案 6 :(得分:2)
如上所述,亚马逊已停止在其api中提供评论。但是,我发现这个很好的教程也可以用python做同样的事情。这是他给出的代码,对我有用!他使用python 2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Written as part of https://www.scrapehero.com/how-to-scrape-amazon-product-reviews-using-python/
from lxml import html
import json
import requests
import json,re
from dateutil import parser as dateparser
from time import sleep
def ParseReviews(asin):
#This script has only been tested with Amazon.com
amazon_url = 'http://www.amazon.com/dp/'+asin
# Add some recent user agent to prevent amazon from blocking the request
# Find some chrome user agent strings here https://udger.com/resources/ua-list/browser-detail?browser=Chrome
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}
page = requests.get(amazon_url,headers = headers).text
parser = html.fromstring(page)
XPATH_AGGREGATE = '//span[@id="acrCustomerReviewText"]'
XPATH_REVIEW_SECTION = '//div[@id="revMHRL"]/div'
XPATH_AGGREGATE_RATING = '//table[@id="histogramTable"]//tr'
XPATH_PRODUCT_NAME = '//h1//span[@id="productTitle"]//text()'
XPATH_PRODUCT_PRICE = '//span[@id="priceblock_ourprice"]/text()'
raw_product_price = parser.xpath(XPATH_PRODUCT_PRICE)
product_price = ''.join(raw_product_price).replace(',','')
raw_product_name = parser.xpath(XPATH_PRODUCT_NAME)
product_name = ''.join(raw_product_name).strip()
total_ratings = parser.xpath(XPATH_AGGREGATE_RATING)
reviews = parser.xpath(XPATH_REVIEW_SECTION)
ratings_dict = {}
reviews_list = []
#grabing the rating section in product page
for ratings in total_ratings:
extracted_rating = ratings.xpath('./td//a//text()')
if extracted_rating:
rating_key = extracted_rating[0]
raw_raing_value = extracted_rating[1]
rating_value = raw_raing_value
if rating_key:
ratings_dict.update({rating_key:rating_value})
#Parsing individual reviews
for review in reviews:
XPATH_RATING ='./div//div//i//text()'
XPATH_REVIEW_HEADER = './div//div//span[contains(@class,"text-bold")]//text()'
XPATH_REVIEW_POSTED_DATE = './/a[contains(@href,"/profile/")]/parent::span/following-sibling::span/text()'
XPATH_REVIEW_TEXT_1 = './/div//span[@class="MHRHead"]//text()'
XPATH_REVIEW_TEXT_2 = './/div//span[@data-action="columnbalancing-showfullreview"]/@data-columnbalancing-showfullreview'
XPATH_REVIEW_COMMENTS = './/a[contains(@class,"commentStripe")]/text()'
XPATH_AUTHOR = './/a[contains(@href,"/profile/")]/parent::span//text()'
XPATH_REVIEW_TEXT_3 = './/div[contains(@id,"dpReviews")]/div/text()'
raw_review_author = review.xpath(XPATH_AUTHOR)
raw_review_rating = review.xpath(XPATH_RATING)
raw_review_header = review.xpath(XPATH_REVIEW_HEADER)
raw_review_posted_date = review.xpath(XPATH_REVIEW_POSTED_DATE)
raw_review_text1 = review.xpath(XPATH_REVIEW_TEXT_1)
raw_review_text2 = review.xpath(XPATH_REVIEW_TEXT_2)
raw_review_text3 = review.xpath(XPATH_REVIEW_TEXT_3)
author = ' '.join(' '.join(raw_review_author).split()).strip('By')
#cleaning data
review_rating = ''.join(raw_review_rating).replace('out of 5 stars','')
review_header = ' '.join(' '.join(raw_review_header).split())
review_posted_date = dateparser.parse(''.join(raw_review_posted_date)).strftime('%d %b %Y')
review_text = ' '.join(' '.join(raw_review_text1).split())
#grabbing hidden comments if present
if raw_review_text2:
json_loaded_review_data = json.loads(raw_review_text2[0])
json_loaded_review_data_text = json_loaded_review_data['rest']
cleaned_json_loaded_review_data_text = re.sub('<.*?>','',json_loaded_review_data_text)
full_review_text = review_text+cleaned_json_loaded_review_data_text
else:
full_review_text = review_text
if not raw_review_text1:
full_review_text = ' '.join(' '.join(raw_review_text3).split())
raw_review_comments = review.xpath(XPATH_REVIEW_COMMENTS)
review_comments = ''.join(raw_review_comments)
review_comments = re.sub('[A-Za-z]','',review_comments).strip()
review_dict = {
'review_comment_count':review_comments,
'review_text':full_review_text,
'review_posted_date':review_posted_date,
'review_header':review_header,
'review_rating':review_rating,
'review_author':author
}
reviews_list.append(review_dict)
data = {
'ratings':ratings_dict,
'reviews':reviews_list,
'url':amazon_url,
'price':product_price,
'name':product_name
}
return data
def ReadAsin():
#Add your own ASINs here
AsinList = ['B01ETPUQ6E','B017HW9DEW']
extracted_data = []
for asin in AsinList:
print "Downloading and processing page http://www.amazon.com/dp/"+asin
extracted_data.append(ParseReviews(asin))
sleep(5)
f=open('data.json','w')
json.dump(extracted_data,f,indent=4)
if __name__ == '__main__':
ReadAsin()
此处是指向其网站reviews scraping with python 2.7
的链接答案 7 :(得分:0)
您可以使用Amazon Product Advertising API。它有一个响应小组&#39;评论&#39;你可以使用它来操作&#39; ItemLookup&#39;。您需要知道ASIN,即产品的唯一商品ID。
设置完所有参数并执行签名后,您将收到一个XML,其中包含指向&#34; IFrameURL&#34;下的客户评论的链接。标签。
使用此URL并使用从此网址返回的html中的模式搜索来提取评论。对于html中的每个评论,都会有一个唯一的评论ID,您可以获得该特定评论的所有数据。
答案 8 :(得分:0)
评论监视工具提供了第三方API。 FeedCheck Review Monitoring API是其中之一。