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 / example_basic_selector.php

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

37 lines 940 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // example of how to use basic selector to retrieve HTML contents
3 include('../simple_html_dom.php');
4
5 // get DOM from URL or file
6 $html = file_get_html('http://www.google.com/');
7
8 // find all link
9 foreach($html->find('a') as $e)
10 echo $e->href . '<br>';
11
12 // find all image
13 foreach($html->find('img') as $e)
14 echo $e->src . '<br>';
15
16 // find all image with full tag
17 foreach($html->find('img') as $e)
18 echo $e->outertext . '<br>';
19
20 // find all div tags with id=gbar
21 foreach($html->find('div#gbar') as $e)
22 echo $e->innertext . '<br>';
23
24 // find all span tags with class=gb1
25 foreach($html->find('span.gb1') as $e)
26 echo $e->outertext . '<br>';
27
28 // find all td tags with attribite align=center
29 foreach($html->find('td[align=center]') as $e)
30 echo $e->innertext . '<br>';
31
32 // extract text from table
33 echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>';
34
35 // extract text from HTML
36 echo $html->plaintext;
37 ?>