ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Codeigniter IMDb Scraper Library

August 25, 2013 11:04am

Subscribe [2]
  • #1 / Aug 25, 2013 11:04am

    Tony0892

    1 posts

    Hello,

    I made an IMDb scraper library to get movie information for a project that i’m working on. And thought I would share it. A quick note, IMDB.com does not allow scraping their site… If this doesn’t bother you(I didn’t), then you can proceed.

    Here are some of the main features:

    *Diffrent scrape options to refine your results
    *Includes a light mode to make searching faster
    *Youtube trailer url in the final results, also has options available in the config
    *More to follow… 

    Example code:
    application/controller/search_controller.php

    //Load the scraper library
    $this->load->library('imdb');
    
    //Check if the query is submitted
    if(isset($this->input->post('query'))) {
        $query = $this->input->post('query'); //Put the query in a variable
        $data['moviedetails'] = $this->imdb->getMovieInfo($query); //Get the movie information
    }
    
    //Set the page title
    $data['title'] = 'IMDb Search Page';
    
    //Load the view and pass along the data
    $this->load->view('search_view', $data);

    application/views/search_view.php

    <!DOCTYPE html>
    <head>
        <title><?php echo $title;></title>
    </head>
    <body>
        <form method="post">
            <input type="text" name="query">
            <input type="submit" value="Search">
        </form>
        
    
        <?php 
            if(isset($moviedetails)){
                foreach($moviedetails as $detail){
                    echo '<pre>';
                    print_r($detail);
                    echo '/<pre>';
                } 
            } 
        ?>
    </body>

    If there any bugs, please report them. Thank you.
    Also, if you have any ideas, suggestions etc, let me know and I’ll try to incorparate them.

    https://github.com/Tony0892/Codeigniter-IMDb-Scraper

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases