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

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

59 lines 1.3 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_generic($url, $search) {
5 // Didn't find it yet.
6 $return = false;
7
8 echo "reading the url: " . $url . "<br/>";
9 // create HTML DOM
10 $html = file_get_html($url);
11 echo "url has been read.<br/>";
12
13 // get article block
14 foreach($html->find($search) as $found) {
15 // Found at least one.
16 $return - true;
17 echo "found a: " . $search . "<br/><pre>";
18 $found->dump();
19 echo "</pre><br/>";
20 }
21
22 // clean up memory
23 $html->clear();
24 unset($html);
25
26 return $return;
27 }
28
29
30 // ------------------------------------------
31 error_log ("post:" . print_r($_POST, true));
32 $url = "";
33 if (isset($_POST['url']))
34 {
35 $url = $_POST['url'];
36 }
37 $search = "";
38 if (isset($_POST['search']))
39 {
40 $search = $_POST['search'];
41 }
42 ?>
43 <form method="post">
44 URL: <input name="url" type="text" value="<?=$url;?>"/><br/>
45 Search: <input name="search" type="text" value="<?=$search;?>"/>
46 <input name="submit" type="submit" value="Submit"/>
47 </form>
48 <?php
49 // -----------------------------------------------------------------------------
50 // test it!
51 if (isset ($_POST['submit']))
52 {
53 $response = scraping_generic($_POST['url'], $_POST['search']);
54 if (!$response)
55 {
56 echo "Did not find any: " . $_POST['search'] . "<br />";
57 }
58 }
59 ?>