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

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

44 lines 1016 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_digg() {
5 // create HTML DOM
6 $html = file_get_html('http://digg.com/');
7
8 // get news block
9 foreach($html->find('div.news-summary') as $article) {
10 // get title
11 $item['title'] = trim($article->find('h3', 0)->plaintext);
12 // get details
13 $item['details'] = trim($article->find('p', 0)->plaintext);
14 // get intro
15 $item['diggs'] = trim($article->find('li a strong', 0)->plaintext);
16
17 $ret[] = $item;
18 }
19
20 // clean up memory
21 $html->clear();
22 unset($html);
23
24 return $ret;
25 }
26
27
28 // -----------------------------------------------------------------------------
29 // test it!
30
31 // "http://digg.com" will check user_agent header...
32 ini_set('user_agent', 'My-Application/2.5');
33
34 $ret = scraping_digg();
35
36 foreach($ret as $v) {
37 echo $v['title'].'<br>';
38 echo '<ul>';
39 echo '<li>'.$v['details'].'</li>';
40 echo '<li>Diggs: '.$v['diggs'].'</li>';
41 echo '</ul>';
42 }
43
44 ?>