Created
June 30, 2017 15:43
-
-
Save divinity76/83d0aaa1cba3a801b1d97600f4ae7f4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types = 1); | |
// hhb_.inc.php from https://github.com/divinity76/hhb_.inc.php/blob/master/hhb_.inc.php | |
require_once ('hhb_.inc.php'); | |
$url = 'https://www.amazon.com/LELO-Smart-Wand-Large-Plum/dp/B008F8J3I4'; | |
$hc = new hhb_curl ( $url, true ); | |
$hc->setopt_array ( array ( | |
CURLOPT_TIMEOUT => 20 | |
) ); | |
$hc->exec (); | |
$html = $hc->getResponseBody (); | |
$domd = @DOMDocument::loadHTML ( $html ); | |
$xpath = new DOMXpath ( $domd ); | |
foreach ( $xpath->query ( './/div[@data-hook=\'review\']', $domd->getElementById ( "cm-cr-dp-review-list" ) ) as $review ) { | |
// var_dump ( $review ); | |
// continue; | |
$stars = $xpath->query ( './/a[contains(@title,\'stars\')]', $review )->item ( 0 )->getAttribute ( "title" ); | |
$author = $xpath->query ( './/a[@data-hook=\'review-author\']', $review )->item ( 0 )->textContent; | |
$date = $xpath->query ( './/span[@data-hook=\'review-date\']', $review )->item ( 0 )->textContent; | |
$text = $xpath->query ( './/div[@data-a-expander-name=\'review_text_read_more\']', $review )->item ( 0 )->textContent; | |
hhb_var_dump ( $stars, $author, $date, $text ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment