PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 1.9.5
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v1.9.5
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / simplehtmldom / example / scraping / example_scraping_imdb.php

example_scraping_imdb.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 1.9.5, at simplehtmldom/example/scraping/example_scraping_imdb.php

51 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 include_once('../../simple_html_dom.php');
3
4 function scraping_IMDB($url) {
5 // create HTML DOM
6 $html = file_get_html($url);
7
8 // get title
9 $ret['Title'] = $html->find('title', 0)->innertext;
10
11 // get rating
12 $ret['Rating'] = $html->find('div[class="general rating"] b', 0)->innertext;
13
14 // get overview
15 foreach($html->find('div[class="info"]') as $div) {
16 // skip user comments
17 if($div->find('h5', 0)->innertext=='User Comments:')
18 return $ret;
19
20 $key = '';
21 $val = '';
22
23 foreach($div->find('*') as $node) {
24 if ($node->tag=='h5')
25 $key = $node->plaintext;
26
27 if ($node->tag=='a' && $node->plaintext!='more')
28 $val .= trim(str_replace("\n", '', $node->plaintext));
29
30 if ($node->tag=='text')
31 $val .= trim(str_replace("\n", '', $node->plaintext));
32 }
33
34 $ret[$key] = $val;
35 }
36
37 // clean up memory
38 $html->clear();
39 unset($html);
40
41 return $ret;
42 }
43
44
45 // -----------------------------------------------------------------------------
46 // test it!
47 $ret = scraping_IMDB('http://imdb.com/title/tt0335266/');
48
49 foreach($ret as $k=>$v)
50 echo '<strong>'.$k.' </strong>'.$v.'<br>';
51 ?>