Skip to content

Instantly share code, notes, and snippets.

@wppurking
Last active March 14, 2017 06:20
Show Gist options
  • Save wppurking/426e8841df881024a881d1e784e068df to your computer and use it in GitHub Desktop.
Save wppurking/426e8841df881024a881d1e784e068df to your computer and use it in GitHub Desktop.
[
{
"tid": "04e9d161-5139-406c-b9ff-e2f96e37a3c5",
"url": "https://www.amazon.ca/product-reviews/B015O9O5D4/ref=cm_cr_arp_d_viewopt_srt?ie=UTF8&filterByStar=all_stars&pageNumber=1&pageSize=50&sortBy=recent",
"callback": "http://44c74ebf.ngrok.io/api/v1/echo",
"rules": [
{
"scope_rule": "//*[@id='cm_cr-review_list']/div[contains(@class,'review')]",
"kv_rule": [
{
"key": "review_id",
"value": "@id"
},
{
"key": "asin",
"value": "descendant::div/a[contains(@class, 'review-title')]/@href",
"script": "'_value_'.split('ASIN=')[1]"
},
{
"key": "variation_asin",
"value": "descendant::div[contains(@class, 'review-data')]/a[contains(@class, 'a-link-normal')]/@href",
"script": "'_value_'.split('/ref=')[0].split('-reviews/')[1]"
},
{
"key": "title",
"value": "div/a[contains(@class,'review-title')]/text()",
"script": "'_value_'.trim()"
},
{
"key": "description",
"value": "div/span[contains(@class,'review-text')]/text()",
"script": "'_value_'.trim()"
},
{
"key": "rating",
"value": "div//i[contains(@class, 'review-rating')]/span/text()",
"script": "'_value_'.split(' out ')[0]"
},
{
"key": "reviewer",
"value": "div/span[contains(@class,'review-byline')]/a/text()"
},
{
"key": "reviewer_id",
"value": "descendant::span[contains(@class, 'review-byline')]/a[contains(@class, 'author')]/@href",
"script": "'_value_'.split('profile/')[1].split('/ref')[0]"
},
{
"key": "verified",
"value": "div[contains(@class, 'review-data')]/span//span[contains(@class, 'a-color-state')]/text()",
"script": "'_value_'.indexOf('Verified') >= 0"
},
{
"key": "images",
"value": "div[contains(@class,'review-image-container')]/div/img/@src"
},
{
"key": "comments",
"value": "descendant::div[contains(@class, 'review-comments')]/descendant::span[@class='review-comment-total']"
},
{
"key": "helpful",
"value": "descendant::div[contains(@class, 'review-comments')]/descendant::span[contains(@class, 'review-votes')]",
"script": "var votes = '_value_'; votes.indexOf('One') >= 0 ? '1' : votes.split(' people')[0]"
},
{
"key": "hof",
"value": "descendant::a[contains(@class, 'c7y-badge-hall-of-fame')]/span/text()"
},
{
"key": "top",
"value": "descendant::span[contains(@class,'c7y-badge-text')]/text()"
},
{
"key": "create_time",
"value": "div//span[contains(@class, 'review-date')]/text()",
"script": "date_format('ca', '_value_', 'on January 2, 2006')"
}
]
},
{
"scope_rule": "//*[@id='cm_cr-pagination_bar']",
"kv_rule": [
{
"key": "has_next",
"value": "descendant::li[@class=\"a-last\"]/a/text()",
"script": "'_value_'.indexOf('Next') >= 0"
}
]
},
{
"scope_rule": "//div[contains(@class, 'page-content')][1]",
"kv_rule": [
{
"key": "total_review_count",
"value": "//span[contains(@class, 'totalReviewCount')]"
}
]
}
]
},
{
"tid": "0ac337ba-bda8-41bf-b2ac-6da7afbfecaf",
"url": "https://www.amazon.ca/review/R1758UPZT8VH9F/ref=cm_cr_rdp_perm?ie=UTF8",
"callback": "http://44c74ebf.ngrok.io/api/v1/review",
"rules": [
{
"scope_rule": "/html/body/table/descendant::tr[1]/td[1]",
"kv_rule": [
{
"key": "review_id",
"value": "descendant::a[1]/@name"
},
{
"key": "title",
"value": "div/div/nobr/preceding-sibling::b/text()",
"script": "'_value_'.trim()"
},
{
"key": "description",
"value": "descendant::div[contains(@class,'reviewText')]/text()",
"script": "'_value_'.trim()"
},
{
"key": "images",
"value": "descendant::img[contains(@class, 'review-image-thumbnail')]/@src"
},
{
"key": "helpful",
"value": "div/div[1]/text()",
"script": "Number('_value_'.split(' of ')[0]).toString()"
},
{
"key": "comments",
"value": "//div[contains(@class, 'cdPageSelectorHeader')]/div[contains(@class, 'cdPageInfo')]",
"script": "'_value_'.split(' of ')[1].split(' posts')[0]"
},
{
"key": "verified",
"value": "descendant::span[contains(@class, 'crVerifiedStripe')]",
"script": "'_value_'.indexOf('Verified') >= 0"
},
{
"key": "reviewer",
"value": "div/div/div/div/a/span/text()"
},
{
"key": "rating",
"value": "div/div/span/img/@title",
"script": "'_value_'.split(' out')[0]"
},
{
"key": "create_time",
"value": "div/div/nobr/text()",
"script": "date_format('ca', '_value_', 'January. 2 2006')"
}
]
},
{
"scope_rule": "//table//td[contains(@class, 'crTanBorder-tc')]",
"kv_rule": [
{
"key": "is_delete",
"value": "//div[contains(@class, 'crLargerTitle')]",
"script": "'_value_'.indexOf(\"We're sorry, but the review\") >= 0"
}
]
}
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment