Giter VIP home page Giter VIP logo

codeigniter_crawler's Introduction

codeigniter_crawler

A website crawler for the CodeIgniter framework

Usage

  1. Copy Crawler.php into the library directory of your CodeIgniter application
  2. codeigniter_crawler has one requirement, Simple_Html_Dom. Download from http://simplehtmldom.sourceforge.net/ and copy Simple_html_dom.php into the libraries directory of your CodeIgniter application.
  3. Load Crawler library from a controller. $this->load->library('crawler');
  4. Set a URL. $this->crawler->set_url('http://github.com');
  5. Use any of the public methods to obtain data from the URL you just set. $this->crawler->get_text();

Public Methods

  • get_text() - Get plain text from the loaded URL.
  • get_title() - Get the meta title from the loaded URL.
  • get_description() - Get the meta description from the loaded URL.
  • get_keywords() - Get the meta keywords from the loaded URL.
  • get_links($excluded_terms, $included_terms) - Get all links from the loaded URL.

Example

Crawl github:

function get_site_data($url, $max_depth = 1, $current_depth = 0){
  $current_depth++;

  $this->load->library('crawler');

	$site_data = array();

	if($this->crawler->set_url($site_url) !== false){
		$site_data['title'] = $this->crawler->get_title();
		$site_data['description'] = $this->crawler->get_description();
		$site_data['keywords'] = $this->crawler->get_keywords();
		$site_data['text'] = $this->crawler->get_text();
		$site_data['links'] = $this->crawler->get_links();

		if($current_depth <= $max_depth){
			foreach($site_data['links'] as $link_key => &$link){
				$link['data'] = get_site_data($link, $max_depth, $current_depth);
				}
			}
		}

		return $site_data;
	}
	else{
		return false;
	}
}

$site_data = get_site_data("http://github.com", 1, 0);

codeigniter_crawler's People

Contributors

lukeas14 avatar

Watchers

 avatar  avatar

Forkers

nibircse

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.