-
Notifications
You must be signed in to change notification settings - Fork 26
/
example.php
41 lines (30 loc) · 1010 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php //defined('BASEPATH') OR exit('No direct script access allowed');
class Cron extends CI_Controller {
public function __construct(){
}
public function index(){
$site_url = "http://github.com";
$site_data = $this->get_site_data($site_url, 1, 0);
}
private function get_site_data($site_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'] = $this->get_site_data($link, $max_depth, $current_depth);
}
}
return $site_data;
}
else{
return false;
}
}
}