simple_html_dom: simple use-case - getting a scipt to work

Joined
Mar 2, 2020
Messages
6
Reaction score
0
_simple_DOM_parser_.jpg
the issue today: simple_html_dom: simple use-case - gettin a scipt to work


Well - this is somewhat a headstart i fairly new to simple_html_dom usage and methods. I know a little the parser,

i want to gather some information from this site:https://europa.eu/youth/volunteering/organisations_en#open

is this possible to get the content - of let us say 10 or 20 last records on that page - and subesquently to store it in my mysql - db!?


Code:
<?php
// Report all PHP errors (see changelog)
error_reporting(E_ALL);


include('inc/simple_html_dom.php');


   //base url
   $base = 'https://europa.eu/youth/volunteering/organisations_en#open';


   //home page HTML
   $html_base = file_get_html( $base );


   //get all category links
   foreach($html_base->find('a') as $element) {
       echo "<pre>";
       print_r( $element->href );
       echo "</pre>";
   }


   $html_base->clear();
   unset($html_base);


?><?php
// Report all PHP errors (see changelog)
error_reporting(E_ALL);


include('inc/simple_html_dom.php');


   //base url
   $base = 'https://europa.eu/youth/volunteering/organisations_en#open';


   //home page HTML
   $html_base = file_get_html( $base );


   //get all category links
   foreach($html_base->find('a') as $element) {
       echo "<pre>";
       print_r( $element->href );
       echo "</pre>";
   }


   $html_base->clear();
   unset($html_base);


?>

I have the above code and I'm trying to get certain elements of the page but it isn't returning anything. Is it possible that certain PHP functions might be disabled on the server to stop that?
The above code works perfectly on other sites.


Code:
<br/>
<b>Warning</b>:  include(inc/simple_html_dom.php): failed to open stream: No such file or directory in <b>[...][...]</b> on line <b>5</b><br/>
<br/>
<b>Warning</b>:  include(): Failed opening 'inc/simple_html_dom.php' for inclusion (include_path='.:') in <b>[...][...]</b> on line <b>5</b><br/>
<br/>
<b>Fatal error</b>:  Uncaught Error: Call to undefined function file_get_html() in [...][...]:11
Stack trace:
#0 {main}
  thrown in <b>[...][...]</b> on line <b>11</b><br/>

findings: As the error states, i think that simple_html_dom.php either doesn't exist or isn't in the right location.

furthermore: since file_get_html is not a native PHP function, the function resides within my included file that cannot be found so i need to to fix that first. The filed does not exist by checking the inc folder in the project root. i am going to fix it.


so the question is:


this is my project-folder:

/project
/project/includes/


question: does the above mentioned file resides in that folder - the includes file!?


love to hear from you
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top