Coder Social home page Coder Social logo

slider23 / caterpillar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cballou/caterpillar

0.0 2.0 0.0 89 KB

Caterpillar is a PHP library intended for website crawling and screen scraping. It handles parallel requests using the curl_multi functions.

License: Other

caterpillar's Introduction

About Caterpillar

Caterpillar is a PHP library intended for website crawling and screen scraping. It handles parallel requests using a modified version of Josh Fraser's Rolling Curl (http://code.google.com/p/rolling-curl/) library which utilizes curl_multi() functions in an efficient manner. You can learn more about Josh and his current projects on his blog, Online Aspect (http://www.onlineaspect.com/).

Because requests are handled in parallel, the fastest completed requests will trigger enqueuing any newly found URLs, ensuring the crawler runs continuously and efficiently. Rolling Curl is set to allow for a maximum number of simultaneous connections to ensure you do not DOS attack the requested host with requests.

Quick Installation

  1. Create a database of your liking and create a user with extended privileges for CREATE TEMPORARY TABLES.

  2. Import the caterpillar.sql file into the database of your choice.

  3. Copy the library to your application and include.

  4. Modify the configuration file /caterpillar/inc/config.inc.php with your MySQL database login credentials.

  5. Use the following example for usage:

    <?php
    require_once('caterpillar.php');
    
    // database configuration params
    $config = array(
        'db_user' => 'your database user',
        'db_pass' => 'your database user password',
        'db_name' => 'the database name',
        'db_host' => '127.0.01'
    );
    
    // instantiate the crawler
    $caterpillar = new Caterpillar(
        'http://www.url-to-crawl.org', 
        $config['db_user'], 
        $config['db_pass'], 
        $config['db_name'], 
        $config['db_host']
    );
    
    // begin crawling, results get stored in database
    $caterpillar->crawl();

Where Are My Results?

After crawling, your database results can be found in the table crawl_index. This table has the following structure:

  • id: A unique, auto-incrementing row identifier.
  • link: The page URL that was crawled.
  • count: The number of times the page url was encountered while crawling your site.
  • filesize: The size of the crawled file in bytes.
  • contenthash: A unique CRC32 hash of the file contents for determining if the file has been updated since last crawled.
  • last_update: A MySQL DATE() value of the last timestamp the page content has been added/updated/changed.
  • last_tested: A MySQL DATE() value of the last timestamp the page has been tested for content changes.

You can easily utilize these results for a number of purposes, i.e. creating a weighted Google Sitemaps XML file based on inbound link popularity of pages.

caterpillar's People

Contributors

cballou avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.