Jump to content

Get last review date (Amazon)


Crayfish
 Share

Recommended Posts

<?php
include('simple_html_dom.php'); //Html dom parser from: https://sourceforge.net/projects/simplehtmldom/files/simple_html_dom.php
$product_id= "B01BGFBUC4";  //Amazon product ID
$url = "http://www.amazon.com/One-Persons-Craziness-R-T-Ojas-ebook/product-reviews/".$product_id."/ref=cm_cr_dp_see_all_btm?ie=UTF8&showViewpoints=1&sortBy=bySubmissionDateDescending&filterByStar=two_star";
$html = file_get_html($url);
$ret = $html->find('div[id=cm_cr-review_list] span[class=a-size-base a-color-secondary review-date]', 0);
$amazonReviewCount = $ret->innertext;
echo "$amazonReviewCount";
?>

Result: on February 28, 2016

 

Is there a way to do this just natively in Autoit?

Link to comment
Share on other sites

One of the many ways

#include <Array.au3>

Local $sProductID = "B01BGFBUC4" ;  //Amazon product ID
Local $sURL = "http://www.amazon.com/One-Persons-Craziness-R-T-Ojas-ebook/product-reviews/" & $sProductID & "/ref=cm_cr_dp_see_all_btm?ie=UTF8&showViewpoints=1&sortBy=bySubmissionDateDescending&filterByStar=two_star";

Local $sSource = BinaryToString(InetRead($sURL, 1))

Local $sReview = StringRegExp($sSource, '(?:<span class="a-size-base a-color-secondary review-date">)(.*?)(?:</span>)', 3)
If Not @error And IsArray($sReview) Then
    _ArrayDisplay($sReview, "DEBUG")
    MsgBox(0, "Last review", $sReview[UBound($sReview) - 1])
EndIf

 

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

Thank you Terenz.  I was attempting with _IEDocReadHTML

Dim $sSrc = _IEDocReadHTML($oIE)
Dim $aMatch = StringRegExp($sSrc, '(?:<span class="a-size-base a-color-secondary review-date">)(.*?)(?:</span>)', 3)

Is there a command to search for the date in the source after a specific id/tag only?

Amazon added 2 sticky reviews in iframe and sometime 3

Example: https://www.amazon.com/One-Persons-Craziness-R-T-Ojas-ebook/product-reviews/B01BGFBUC4/ref=cm_cr_arp_d_viewopt_sr?ie=UTF&showViewpoints=1&sortBy=bySubmissionDateDescending&filterByStar=all_stars&pageNumber=1

Pull after the last actual review and not the top critic, or top comments, or top positive.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...