-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
62 lines (61 loc) · 1.85 KB
/
main.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
<?php
$a=getopt("p:");
if(count($a['p'])>1){
$url=file_get_contents($a['p'][0]);
$doc = new DOMDocument();
@$doc->loadHTML($url);
$mime=intval($a['p'][1]);
echo "Media-Graper @ https://github.com/davidmillerpak/Media-Graper ";
if($mime==2){
$tags = $doc->getElementsByTagName('video');
echo "saved ".count($tags)." Results.\n\n";
foreach ($tags as $tag) {
echo $tag->getAttribute('src')."\n";
}
}else if($mime==3){
$tags = $doc->getElementsByTagName('a');
echo "saved ".count($tags)." Results.\n\n";
foreach ($tags as $tag) {
echo $tag->getAttribute('href')."\n";
}
}else if($mime==4){
$tags = $doc->getElementsByTagName('meta');
echo "saved ".count($tags)." Results.\n\n";
foreach ($tags as $tag) {
if(!empty($tag->getAttribute('name'))){
$mtn=$tag->getAttribute('name');
}else if(!empty($tag->getAttribute('property'))){
$mtn=$tag->getAttribute('property');
}else{
$mtn="unnamed";
}
echo $mtn." - ".$tag->getAttribute('content')."\n";
}
}else if($mime==5){
$tags = $doc->getElementsByTagName('script');
echo "saved ".count($tags)." Results.\n\n";
foreach ($tags as $tag) {
if(!empty($tag->getAttribute('src'))){
echo $tag->getAttribute('src')."\n";
}else{
echo "Internal Scripts.\n";
}
}
}else if($mime==6){
$tags = $doc->getElementsByTagName('link');
echo "saved ".count($tags)." Results.\n\n";
foreach ($tags as $tag) {
if(!empty($tag->getAttribute('rel')) && $tag->getAttribute('rel')=="stylesheet"){
echo $tag->getAttribute('href')."\n";
}else{
echo "Internal Stylesheets.\n";
}
}
}else{
$tags = $doc->getElementsByTagName('img');
echo "saved ".count($tags)." Results.\n\n";
foreach ($tags as $tag) {
echo $tag->getAttribute('src')."\n";
}
}
}