Skip to content

Instantly share code, notes, and snippets.

@meganechan
Created July 7, 2012 18:10
Show Gist options
  • Save meganechan/3067489 to your computer and use it in GitHub Desktop.
Save meganechan/3067489 to your computer and use it in GitHub Desktop.
Get Manga
<form name="form1" method="post" action="">
<label for="link"></label>
ใส่ลิงค์ไฟล์
<input type="text" name="link" id="link">
<input type="submit" name="button" id="button" value="Submit">
</form>
<?
set_time_limit(5000000);
function getLinks($link){
global $i;
$ret = array();
$dom = new domDocument;
@$dom->loadHTML(file_get_contents($link));
$dom->preserveWhiteSpace = false;
$links = $dom->getElementsByTagName('script');
foreach ($links as $tag){
$ret= $tag->childNodes->item(0)->nodeValue;
}
return $ret;
}
if (isset($_POST['link'])){
$test=getLinks($_POST['link']);
$arr = explode ( '"', $test );
$num=count($arr);
if (!file_exists($arr[1])) {
mkdir($arr[1]);
}
$a=0;
for ($i=0;$i<$num;$i++){
if ( ereg ( "([0-9]+(\.[0-9]+){3})", $arr[$i]) ){
$url=$arr[$i];
}
if ( ereg ( "jpg$|png$", $arr[$i],$type) ){
$file[$a]=$arr[$i];
$a++;
}
//
}
}
for ($i=0;$i<$num;$i++){
copy($url.$file[$i],"./".$arr[1]."/".$i.".".$type[0]);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment