-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrippercli.php
executable file
·44 lines (40 loc) · 1.21 KB
/
rippercli.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
<?php
/**
* Script By Ervin Sabic
* Published under GPL
* Feel free to do whatever you please with this script.
* Website: www.gearsite.net
* Desc: PHP CLI Script that is used to pull data from a website. Useful for when you need to move hundreds of images and want to organize them.
*/
require("sabicripper.php");
$ripper = new Ripper($argv, $argc);
$ripper->init();
$html = $ripper->scrapeHtml($ripper->getSource());
$imageSources = $ripper->scrapeImageSources($html);
$acceptedFormats = [
'jpg', 'png', 'tiff', 'gif', 'bmp', 'svg', 'pdf',
];
foreach($imageSources as $key=>$source){
$imageSources[$key] = washUrl($source, $acceptedFormats);
echo $imageSources[$key];
}
var_dump($imageSources);
$imageSources = $ripper->uniqueFilter($imageSources);
$ripper->scrapeImages($imageSources);
/**
* Get the first images which is what we're looking for. Custom Filter
*/
function washURL($url, $options){
$noMatch = true;
while($noMatch){
foreach($options as $check){
$check = ".".$check;
if(strpos($url, $check) !== false){
$noMatch = false;
return substr($url, 0, strpos($url, $check)+strlen($check))."\n";
}
}
$noMatch = false;
}
}
?>