Last active
January 18, 2021 09:34
-
-
Save saasindustries/4fe7a6d0eea92d1ce77a2edf7f09ed0d 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
$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