Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8393289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:44:36+00:00 2026-06-09T19:44:36+00:00

Possible Duplicate: Screen scapingin in php using file_get_contents Can anyone help me.. I am

  • 0

Possible Duplicate:
Screen scapingin in php using file_get_contents

Can anyone help me.. I am trying to scrape Hotel reviews from LateRooms.com dont tell me its a bad idea because I already have permission as an affiliate

My code:

<?php
header('content-type: text/plain');

$contents = file_get_contents('http://www.laterooms.com/en/hotel-reviews/238902_the-westfield-bb-sandown.aspx');
$contents = preg_replace('/\s(1,)/', ' ', $contents);

print $contents . "\n";

$records = preg_split('/<div id="review/', $contents);

for ($ix = 1; $ix < count($records); $ix++) {

$tmp = $records[$ix];

preg_match('/id="review"/', $tmp, $match_reviews);

print_r($match_reviews);

exit();

}
?>

This works really well the only problem is that It pulls in the whole page of code and doesnt match the div id ‘review’

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:44:37+00:00Added an answer on June 9, 2026 at 7:44 pm
    function file_get_contents_curl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    
    $data = curl_exec($ch);
    curl_close($ch);
    
    return $data;
    }
    function DOMinnerHTML($element){ 
    $innerHTML = ""; 
    $children = $element->childNodes; 
    foreach ($children as $child) 
    { 
        $tmp_dom = new DOMDocument(); 
        $tmp_dom->appendChild($tmp_dom->importNode($child, true)); 
        $innerHTML.=trim($tmp_dom->saveHTML()); 
    } 
    return $innerHTML; 
    }
    $url  = 'http://www.laterooms.com/en/hotel-reviews/238902_the-westfield-bb-sandown.aspx';
    $html = file_get_contents_curl($url);
    
    //parsing begins here:
    $doc = new DOMDocument();
    @$doc->loadHTML($html);
    $div_elements = $doc->getElementsByTagName('div');
    
    if ($div_elements->length <> 0){
    foreach ($div_elements as $div_element) {
        if ($div_element->getAttribute('class') == 'review newReview'){
            $reviews[] = DOMinnerHTML($div_element);
    
        }
    }
    }
    
    print_r($reviews);
    

    Try this, it will return all reviews. You can refine the content as per your requirement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can i override HOME Button on my own Home-Screen from my application?
Possible Duplicate: Getting the screen resolution using PHP well the question is self explanatory
Possible Duplicate: C# full screen console? I am trying to make one of my
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can you do Desktop Development using JavaScript? I am very familiar with
Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
Possible Duplicate: Screen Scraping from a web page with a lot of Javascript I
Possible Duplicate: Android Left to Right slide animation Can i make the screen that
Possible Duplicate: Website screenshots using PHP I was wondering if it is possible to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.