Screen scapingin in php using file_get_contents

后端 未结 1 1803
夕颜
夕颜 2021-01-29 11:43

Hi I am very new to screen scraping. I am trying to scrape reviews from a hotel booking webite to display on to mine..

Ive got this far but got a bit stuck. Can anyone h

相关标签:
1条回答
  • 2021-01-29 12:19

    use DomDocument

    <?php
      define('URL', 'http://www.laterooms.com/en/hotel-reviews/238902_the-westfield-bb-sandown.aspx');
      $doc = new DOMDocument();
      $doc->loadHTML(file_get_contents(URL));
      $summary = $doc->getElementById('summary');
      // also have $doc->getElementsByTagName , etc
      var_export($summary);
    ?>
    

    Also, for more complicated queries you should consider looking into XPATH (uses jQuery-like syntax)

    0 讨论(0)
提交回复
热议问题