/// <summary>
/// Given a specific product result html, provides the review histogram
/// html. Used for obtaining review count and review distribution.
/// </summary>
/// <param name="itemHtml"></param>
/// <returns>string html of review histogram</returns>
public static string GetReviewHistogramHtml(string itemHtml)
{
// To get the review information without loading an entire new page,
// we will call the review histogram popup URL instead of the main URL
// We need the ASIN of the product to make the call, which is in the same
// DIV tag as the product result #:
string productASINPattern = @"(?<=name="").*?(?="">)";
string match = GetSingleRegExMatch(itemHtml, productASINPattern);
// Occassionally Amazon adds attributes to the end of the tag, so
// find the end of attribute containing the ASIN (should be the first
// double quote we encounter).
int endAttributeIndex = match.IndexOf('"');
if (endAttributeIndex > 0)
{
// Truncate anything after
match = match.Substring(0, endAttributeIndex);
}
if (match.Length == 0)
{
return(null);
}
// With the product ASIN, make the httprequest to get the review popup data
return(Scraper.LoadReviewHistogram(match));
}