driver = webdriver.Chrome()
driver.get("https://www.amazon.de/gp/customer-reviews/xxxxxxxxxxxxxxx/ref_=bcr_shw_rev_dtl")
time.sleep(1)
# comment_account_id and comment_account_name
# 通过评论链接获取评论账号id和名字
if com_amz_x.check_driver_is_exists_by_x_path(driver, "//div[@data-hook='genome-widget']") == 1:
gp_profile = com_amz_x.find_element(driver, "//div[@data-hook='genome-widget']")
a_link = com_amz_x.find_element(gp_profile, "//a[@class='a-profile']")
comment_account_id = com_amz_x.get_attribute(a_link, "href")
if comment_account_id is not None and comment_account_id != "":
comment_account_id = comment_account_id.split("gp/profile/")[1]
comment_account_id = comment_account_id.split("/")[0]
print(comment_account_id)
el_comment_account_name = com_amz_x.find_element(gp_profile, "//span[@class='a-profile-name']")
comment_account_name = com_amz_x.get_attribute(el_comment_account_name, "innerText")
comment_account_name.replace("'", "")
print(comment_account_name)
else:
print(000)
自动化获取数据,不需要登录买家账号。