Results 1 to 4 of 4

Thread: simple_html_dom: simple use-case - gettin a scipt to work

  1. #1

    Default simple_html_dom: simple use-case - gettin a scipt to work

    hi there good day dear OpenSuse-experts,

    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...ations_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





    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

  2. #2

    Default Re: simple_html_dom: simple use-case - gettin a scipt to work


    it looks like so:

    C:Users\Kasper\Documents\_mk_\_dev_\php\ ->here my_project-file_
    C:Users\Kasper\Documents\_mk_\_dev_\php\includes (and here the "simplehtmldom-parser" from https://sourceforge.net/projects/simplehtmldom/ goes in
    i am going to testrun now the whole thing on my machine - using ATOM

    i come back later the day
    love to hear from you
    regards
    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

  3. #3
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    20,830
    Blog Entries
    14

    Default Re: simple_html_dom: simple use-case - gettin a scipt to work

    You have a folder 'includes' where the script looks in 'inc'.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  4. #4

    Default Re: simple_html_dom: simple use-case - gettin a scipt to work

    ohhhhhhhhhhhhhhhhhhhhh - youre right dear knurpht.

    many thanks for this valuable hint!!

    i am going to correct it!!
    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •