PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 1.9.4
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v1.9.4
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_slashdot.php

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

35 lines 795 B
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_slashdot() {
5 // create HTML DOM
6 $html = file_get_html('http://slashdot.org/');
7
8 // get article block
9 foreach($html->find('div[id^=firehose-]') as $article) {
10 // get title
11 $item['title'] = trim($article->find('a.datitle', 0)->plaintext);
12 // get body
13 $item['body'] = trim($article->find('div.body', 0)->plaintext);
14
15 $ret[] = $item;
16 }
17
18 // clean up memory
19 $html->clear();
20 unset($html);
21
22 return $ret;
23 }
24
25 // -----------------------------------------------------------------------------
26 // test it!
27 $ret = scraping_slashdot();
28
29 foreach($ret as $v) {
30 echo $v['title'].'<br>';
31 echo '<ul>';
32 echo '<li>'.$v['body'].'</li>';
33 echo '</ul>';
34 }
35 ?>