|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PiedWeb\SeoPocketCrawler; |
|
4
|
|
|
|
|
5
|
|
|
use PiedWeb\UrlHarvester\Harvest; |
|
6
|
|
|
|
|
7
|
|
|
/* http://www.convertcsv.com/csv-to-sql.htm |
|
8
|
|
|
CREATE TABLE mytable( |
|
9
|
|
|
id INTEGER NOT NULL PRIMARY KEY |
|
10
|
|
|
,discovered INTEGER NOT NULL |
|
11
|
|
|
,uri VARCHAR(400) NOT NULL |
|
12
|
|
|
,updated_at DATE |
|
13
|
|
|
,click INTEGER NOT NULL |
|
14
|
|
|
,inboundlinks INTEGER NOT NULL |
|
15
|
|
|
,can_be_crawled BIT NOT NULL |
|
16
|
|
|
,indexable BIT NOT NULL |
|
17
|
|
|
,mime_type VARCHAR(10) NOT NULL |
|
18
|
|
|
,links INTEGER NOT NULL |
|
19
|
|
|
,links_duplicate INTEGER NOT NULL |
|
20
|
|
|
,links_self BIT NOT NULL |
|
21
|
|
|
,links_internal INTEGER NOT NULL |
|
22
|
|
|
,links_sub BIT NOT NULL |
|
23
|
|
|
,links_external INTEGER NOT NULL |
|
24
|
|
|
,ratio_text_code INTEGER NOT NULL |
|
25
|
|
|
,load_time NUMERIC(8,6) NOT NULL |
|
26
|
|
|
,size INTEGER NOT NULL |
|
27
|
|
|
,title VARCHAR(90) |
|
28
|
|
|
,kws VARCHAR(94) NOT NULL |
|
29
|
|
|
,h1 VARCHAR(84) NOT NULL |
|
30
|
|
|
,breadcrumb_level INTEGER |
|
31
|
|
|
,breadcrumb_first VARCHAR(16) |
|
32
|
|
|
,breadcrumb_text VARCHAR(41) |
|
33
|
|
|
); |
|
34
|
|
|
*/ |
|
35
|
|
|
class Url |
|
36
|
|
|
{ |
|
37
|
|
|
private static $autoIncrement = 1; |
|
38
|
|
|
|
|
39
|
|
|
public $id; |
|
40
|
|
|
public $discovered; |
|
41
|
|
|
public $uri; |
|
42
|
|
|
public $updated_at; |
|
43
|
|
|
public $click; |
|
44
|
|
|
public $inboundlinks; |
|
45
|
|
|
public $can_be_crawled; |
|
46
|
|
|
public $indexable; |
|
47
|
|
|
public $mime_type; |
|
48
|
|
|
public $links; |
|
49
|
|
|
public $links_duplicate; |
|
50
|
|
|
public $links_self; |
|
51
|
|
|
public $links_internal; |
|
52
|
|
|
public $links_sub; |
|
53
|
|
|
public $links_external; |
|
54
|
|
|
public $ratio_text_code; |
|
55
|
|
|
public $load_time; |
|
56
|
|
|
public $size; |
|
57
|
|
|
public $title; |
|
58
|
|
|
public $kws; |
|
59
|
|
|
public $h1; |
|
60
|
|
|
public $breadcrumb_level; |
|
61
|
|
|
public $breadcrumb_first; |
|
62
|
|
|
public $breadcrumb_text; |
|
63
|
|
|
|
|
64
|
6 |
|
public function __construct($url, $click) |
|
65
|
|
|
{ |
|
66
|
6 |
|
$this->id = $this->getId(); |
|
67
|
6 |
|
$this->uri = substr($url, strlen(Harvest::getDomainAndSchemeFrom($url))); |
|
68
|
6 |
|
$this->updated_at = date('Ymd'); |
|
69
|
6 |
|
$this->inboundlinks = 0; |
|
70
|
6 |
|
$this->click = $click; |
|
71
|
6 |
|
} |
|
72
|
|
|
|
|
73
|
6 |
|
public function getId() |
|
74
|
|
|
{ |
|
75
|
6 |
|
if (null === $this->id) { |
|
76
|
6 |
|
$this->id = self::$autoIncrement; |
|
77
|
6 |
|
++self::$autoIncrement; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
6 |
|
return $this->id; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
6 |
|
public function setDiscovered(int $discovered) |
|
84
|
|
|
{ |
|
85
|
6 |
|
$this->discovered = $discovered; |
|
86
|
|
|
|
|
87
|
6 |
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|