Skip to content

Instantly share code, notes, and snippets.

@saasindustries
Last active January 18, 2021 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saasindustries/4fe7a6d0eea92d1ce77a2edf7f09ed0d to your computer and use it in GitHub Desktop.
Save saasindustries/4fe7a6d0eea92d1ce77a2edf7f09ed0d to your computer and use it in GitHub Desktop.
$results = array();
if (!empty($html)) {
$div_class = $title = "";
$i = 0;
foreach ($html->find(".review-container") as $div_class) {
//Extract the review title
foreach ($div_class->find(".title") as $title) {
$results[$i]['title'] = $title->plaintext;
}
//Extract the number of star ratings
foreach ($div_class->find(".ipl-ratings-bar") as $ratings) {
$results[$i]['ratings'] = $ratings->plaintext;
}
//Extract the review content
foreach ($div_class->find('div[class=text show-more__control]') as $description) {
$content = html_entity_decode($description->plaintext);
$content = preg_replace('/\'/', "", $content);
$results[$i]['description'] = html_entity_decode($content);
}
$i++;
}
}
print_r($results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment