-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextractors.php
74 lines (54 loc) · 1.53 KB
/
extractors.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
// Definiert Extraktoren
interface iExtractor {
function is_able($url);
function extract($source);
}
class ExFlickr implements iExtractor {
function is_able($url) {
return strpos($url, 'flickr.com/') !== false;
}
function extract($source) {
$data = array();
// Titel extrahieren
preg_match('/<title>(.*?)<\/title>/', $source, $matches);
$data['title'] = $matches[1];
// Bild extrahieren
preg_match('/<meta property="og:image" content="(.*?)" \/>/', $source, $matches);
$data['image'] = $matches[1];
return $data;
}
}
$extractor[] = new ExFlickr();
class ExDeviantArt implements iExtractor {
function is_able($url) {
return strpos($url, 'deviantart.com/') !== false;
}
function extract($source) {
$data = array();
// Titel extrahieren
preg_match('/<title>(.*?)<\/title>/', $source, $matches);
$data['title'] = $matches[1];
// Bild extrahieren
preg_match('/<meta name="og:image" content="(.*?)">/', $source, $matches);
$data['image'] = $matches[1];
return $data;
}
}
$extractor[] = new ExDeviantArt();
class Ex500px implements iExtractor {
function is_able($url) {
return strpos($url, '500px.com/') !== false;
}
function extract($source) {
$data = array();
// Titel extrahieren
preg_match('/<title>(.*?)<\/title>/', $source, $matches);
$data['title'] = $matches[1];
// Bild extrahieren
preg_match('/<meta property="twitter:image:src" value="(.*?)" \/>/', $source, $matches);
$data['image'] = $matches[1];
return $data;
}
}
$extractor[] = new Ex500px();