mirror of
https://github.com/hakasenyang/marumaru-php-parser
synced 2026-08-22 02:03:08 +09:00
여러 내용 수정...
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2017 hakasenyang
|
||||
Copyright (c) 2016-2018 hakasenyang
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+185
-6
@@ -1,7 +1,43 @@
|
||||
<?php
|
||||
class Marumaru {
|
||||
private $httph = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36';
|
||||
private $fname = 'cookie.txt';
|
||||
private $httph = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36';
|
||||
private $fname = 'cookie_hidden.txt';
|
||||
|
||||
public function linkencode ($url) {
|
||||
$ta = parse_url($url);
|
||||
if (!empty($ta['scheme']))
|
||||
$ta['scheme'] .= '://';
|
||||
if (!empty($ta['pass']) and !empty($ta['user']))
|
||||
{
|
||||
$ta['user'] = ':';
|
||||
$ta['pass'] = rawurlencode($ta['pass']).'@';
|
||||
}
|
||||
elseif (!empty($ta['user']))
|
||||
$ta['user'] .= '@';
|
||||
|
||||
if (!empty($ta['port']) and !empty($ta['host']))
|
||||
$ta['host'] = ''.$ta['host'].':';
|
||||
elseif (!empty($ta['host']))
|
||||
$ta['host'] = $ta['host'];
|
||||
|
||||
if (!empty($ta['path']))
|
||||
{
|
||||
$tu = '';
|
||||
$tok = strtok($ta['path'], "\\/");
|
||||
while (strlen($tok))
|
||||
{
|
||||
$tu .= rawurlencode($tok).'/';
|
||||
$tok = strtok("\\/");
|
||||
}
|
||||
$ta['path'] = '/'.trim($tu, '/');
|
||||
}
|
||||
if (!empty($ta['query']))
|
||||
$ta['query'] = '?'.$ta['query'];
|
||||
if (!empty($ta['fragment']))
|
||||
$ta['fragment'] = '#'.$ta['fragment'];
|
||||
|
||||
return implode('', array($ta['scheme'], $ta['user'], $ta['pass'], $ta['host'], $ta['port'], $ta['path'], $ta['query'], $ta['fragment']));
|
||||
}
|
||||
public function splits($data, $first, $end, $num = 1)
|
||||
{
|
||||
$temp = @explode($first, $data);
|
||||
@@ -11,11 +47,13 @@
|
||||
}
|
||||
public function WEBParsing($url, $cookie=NULL, $headershow=TRUE, $postparam=NULL, $otherheader=NULL)
|
||||
{
|
||||
if (!preg_match('/^(?:https?):\/\//', $url)) return false;
|
||||
$ch = curl_init();
|
||||
$url = $this->linkencode($url);
|
||||
$opts = array(CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
CURLOPT_CONNECTTIMEOUT => 5,
|
||||
CURLOPT_TIMEOUT => 60,
|
||||
CURLOPT_CONNECTTIMEOUT => 10,
|
||||
CURLOPT_SSL_VERIFYPEER => FALSE,
|
||||
CURLOPT_HEADER => $headershow,
|
||||
CURLOPT_USERAGENT => $this->httph
|
||||
@@ -35,6 +73,144 @@
|
||||
curl_close($ch);
|
||||
return ($data) ? $data : false;
|
||||
}
|
||||
/**
|
||||
* sucuri - sucuri 프록시 관련 쿠키 우회
|
||||
* 소스 : https://github.com/organization/cloudflare-bypass
|
||||
* 소스 : http://cafe.naver.com/gogoomas/337647
|
||||
* @param string $result 쿠키 string 입력
|
||||
* @return strring 쿠키 데이터 출력
|
||||
* 사용하지 않음.
|
||||
*/
|
||||
/*public function sucuri($result)
|
||||
{
|
||||
if(strpos($result, 'sucuri_cloudproxy_js') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('S=\'', $result);
|
||||
$cp_temp2 = explode(';', $cp_temp1[1]);
|
||||
$cp_script = $cp_temp2[0];
|
||||
$cp_temp1 = explode('A=\'', $result);
|
||||
$cp_temp2 = explode('\';', $cp_temp1[1]);
|
||||
$cp_chlist = $cp_temp2[0];
|
||||
$cp_charr = array();
|
||||
for($i = 0; $i < 64; $i++)
|
||||
$cp_charr[$cp_chlist[$i]] = $i;
|
||||
$cp_len = strlen($cp_script);
|
||||
$cp_c = 0;
|
||||
$cp_u = 0;
|
||||
$cp_i = 0;
|
||||
$cp_l = 0;
|
||||
$cp_a = NULL;
|
||||
$cp_r = NULL;
|
||||
for($i = 0; $i < $cp_len; $i++)
|
||||
{
|
||||
$cp_c = $cp_charr[$cp_script[$i]];
|
||||
$cp_u = ($cp_u << 6) + $cp_c;
|
||||
$cp_l += 6;
|
||||
while($cp_l >= 8)
|
||||
(($cp_a = ($cp_u >> ($cp_l -= 8)) & 0xff) || ($cp_i < ($cp_len - 2))) && ($cp_r .= chr($cp_a));
|
||||
}
|
||||
$cp_temp1 = explode('document.cookie=', $cp_r);
|
||||
$cp_temp2 = explode('=', $cp_temp1[1]);
|
||||
$cp_cnam = str_replace('"', '\'', $cp_temp2[0]);
|
||||
$cp_cnam_split = explode('+', $cp_cnam);
|
||||
$cp_cnam_split_cnt = count($cp_cnam_split);
|
||||
$cp_cnam_string = NULL;
|
||||
for($i = 0 ; $i < $cp_cnam_split_cnt; $i++)
|
||||
{
|
||||
$cp_cnam = trim($cp_cnam_split[$i]);
|
||||
if(strpos($cp_cnam, 'slice') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('\'', $cp_cnam);
|
||||
$cp_temp2 = explode('(', $cp_cnam);
|
||||
$cp_temp3 = explode(')', $cp_temp2[1]);
|
||||
$cp_temp4 = explode(',', $cp_temp3[0]);
|
||||
$cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp4[0]), (intval(trim($cp_temp4[1])-trim($cp_temp4[0]))));
|
||||
}
|
||||
elseif(strpos($cp_cnam, 'charAt') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('\'', $cp_cnam);
|
||||
$cp_temp2 = explode('(', $cp_cnam);
|
||||
$cp_temp3 = explode(')', $cp_temp2[1]);
|
||||
$cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp3[0]), 1);
|
||||
}
|
||||
elseif(strpos($cp_cnam, 'String.fromCharCode') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('(', $cp_cnam);
|
||||
$cp_temp2 = explode(')', $cp_temp1[1]);
|
||||
if(strpos($cp_temp2[0], '0x') !== false)
|
||||
$cp_cnam_string .= chr(hexdec($cp_temp2[0]));
|
||||
else
|
||||
$cp_cnam_string .= chr($cp_temp2[0]);
|
||||
}
|
||||
elseif(strpos($cp_cnam, 'substr') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('\'', $cp_cnam);
|
||||
$cp_temp2 = explode('(', $cp_cnam);
|
||||
$cp_temp3 = explode(')', $cp_temp2[1]);
|
||||
$cp_temp4 = explode(',', $cp_temp3[0]);
|
||||
$cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp4[0]), trim($cp_temp4[1]));
|
||||
}
|
||||
else
|
||||
$cp_cnam_string .= trim(trim($cp_cnam, '\''));
|
||||
$cp_cnam_string .= NULL;
|
||||
}
|
||||
//$cp_temp1 = explode('=', $cp_r);
|
||||
$cp_temp1 = strpos($cp_r, '=');
|
||||
$cp_temp2 = explode(';document.cookie', substr($cp_r, $cp_temp1+1)); //$cp_temp[1]
|
||||
$cp_cval = str_replace('"', '\'', $cp_temp2[0]);
|
||||
$cp_cval_split = explode('+', $cp_cval);
|
||||
$cp_cval_split_cnt = count($cp_cval_split);
|
||||
$cp_cval_string = null;
|
||||
for($i = 0 ; $i < $cp_cval_split_cnt; $i++)
|
||||
{
|
||||
$cp_nval = trim($cp_cval_split[$i]);
|
||||
if(strpos($cp_nval, 'slice') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('\'', $cp_nval);
|
||||
$cp_temp2 = explode('(', $cp_nval);
|
||||
$cp_temp3 = explode(')', $cp_temp2[1]);
|
||||
$cp_temp4 = explode(',', $cp_temp3[0]);
|
||||
$cp_cval_string .= substr($cp_temp1[1], trim($cp_temp4[0]), (intval(trim($cp_temp4[1])-trim($cp_temp4[0]))));
|
||||
}
|
||||
elseif(strpos($cp_nval, 'charAt') !== false)
|
||||
{
|
||||
$cp_temp1 = explode("'", $cp_nval);
|
||||
$cp_temp2 = explode("(", $cp_nval);
|
||||
$cp_temp3 = explode(")", $cp_temp2[1]);
|
||||
$cp_cval_string .= substr($cp_temp1[1], trim($cp_temp3[0]), 1);
|
||||
}
|
||||
elseif(strpos($cp_nval, 'String.fromCharCode') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('(', $cp_nval);
|
||||
$cp_temp2 = explode(')', $cp_temp1[1]);
|
||||
if(strpos($cp_temp2[0], '0x') !== false)
|
||||
{
|
||||
$cp_cval_string .= chr(hexdec($cp_temp2[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$cp_cval_string .= chr($cp_temp2[0]);
|
||||
}
|
||||
}
|
||||
elseif(strpos($cp_nval, 'substr') !== false)
|
||||
{
|
||||
$cp_temp1 = explode('\'', $cp_nval);
|
||||
$cp_temp2 = explode('(', $cp_nval);
|
||||
$cp_temp3 = explode(')', $cp_temp2[1]);
|
||||
$cp_temp4 = explode(',', $cp_temp3[0]);
|
||||
$cp_cval_string .= substr($cp_temp1[1], trim($cp_temp4[0]), trim($cp_temp4[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$cp_cval_string .= trim(trim($cp_nval, '\''));
|
||||
}
|
||||
$cp_cval_string .= NULL;
|
||||
}
|
||||
|
||||
// String Output
|
||||
return $cp_cnam_string."=".$cp_cval_string;
|
||||
}
|
||||
}*/
|
||||
public function FileRead($filename=NULL)
|
||||
{
|
||||
$filename = ($filename) ? $filename : $this->fname;
|
||||
@@ -55,6 +231,9 @@
|
||||
}
|
||||
public function GetCookie()
|
||||
{
|
||||
/*$data = $this->WEBParsing('http://wasabisyrup.com/archives/');
|
||||
$cookie = $this->splits($data, '<script>', '</script>');
|
||||
$cookie = $this->sucuri($cookie);*/
|
||||
$data = $this->WEBParsing('http://wasabisyrup.com/archives/455742', $cookie, true, 'pass=qndxkr',
|
||||
array(
|
||||
'Referer: http://wasabisyrup.com/'
|
||||
@@ -88,9 +267,9 @@
|
||||
$err='Not found comics data';
|
||||
break;
|
||||
default:
|
||||
$err='Unknown Error. Please send me an e-mail (contact@hakase.kr)';
|
||||
$err='Unknown Error. Please send me an e-mail (hakase@hakase.io)';
|
||||
}
|
||||
die(json_encode(array('error'=>$num, 'message'=>$err)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,15 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=500, user-scalable=no">
|
||||
<title>fmaru php porting by hakase</title>
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
|
||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css"> -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
|
||||
<!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
||||
rel="stylesheet">-->
|
||||
<link href="style.css"
|
||||
rel="stylesheet">
|
||||
<link href="style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body style="margin:0px">
|
||||
<div id="contents"></div>
|
||||
<script src="config.js?2017010701"></script>
|
||||
<script src="app.js?2017010701"></script>
|
||||
<script src="config.js?2018021101"></script>
|
||||
<script src="app.js?2018021101"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -8,16 +8,6 @@
|
||||
if(isset($imgurl))
|
||||
{
|
||||
$a = parse_url($imgurl);
|
||||
// Insecure checkup causes RFI
|
||||
switch($a['scheme'])
|
||||
{
|
||||
case 'http':
|
||||
case 'https':
|
||||
break;
|
||||
default:
|
||||
exit;
|
||||
}
|
||||
|
||||
switch($a['host'])
|
||||
{
|
||||
case 'www.yuncomics.com':
|
||||
@@ -40,7 +30,6 @@
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
header('Cache-Control: max-age=86400, public');
|
||||
header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 86400));
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s',time() + 86400 ) . ' GMT' );
|
||||
@@ -80,11 +69,11 @@ Number 2 : Cookie Get Error<br>
|
||||
Number 3 : Password Error (Protected archive) - Retry 10 minutes after view or retry about 3 times)<br>
|
||||
Number 4 : Not found comics data<br>
|
||||
Other error : read the message</p>
|
||||
<p>Output only JSON (Example) {"error":1,"message":"Error Message)"}<br>
|
||||
<p>Output only JSON (Example) {"error":1,"message":"Error Message"}<br>
|
||||
Only error / message method use</p>
|
||||
<h2>Etc...</h2>
|
||||
<p><strong><i><u><a href="https://github.com/hakasenyang/marumaru-php-parser" target="_blank">Open Source</a></u></i></strong></p>
|
||||
<p>Developed by <a href="https://keybase.io/hakasekr" rel="noreferrer" target="_blank">Hakase</a> (contact@hakase.kr)<br>
|
||||
<p>Developed by <a href="https://keybase.io/hakasekr" rel="noreferrer" target="_blank">Hakase</a> (hakase@hakase.io)<br>
|
||||
사용은 자유고 제한 없음. 애초에 제한 있으면 API 인증키를 넣겠지만 귀찮아서 안 넣음.
|
||||
</p>
|
||||
</body>
|
||||
@@ -145,13 +134,12 @@ startdata:
|
||||
if ($image)
|
||||
{
|
||||
$jsonon = ($_GET['json'] == 1) ? true : false;
|
||||
|
||||
for($i=1;$i<count($aaa);$i++)
|
||||
for($i=1,$cnt=(count($aaa));$i<$cnt;$i++)
|
||||
echo '<img src="?imgurl='.urlencode(trim(explode('"', $aaa[$i])[0])).'"><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
for($i=1;$i<count($data2);$i++)
|
||||
for($i=1,$cnt=count($data2);$i<$cnt;$i++)
|
||||
{
|
||||
if($num == trim(explode('" >', $data2[$i])[0]))
|
||||
{
|
||||
@@ -180,7 +168,7 @@ startdata:
|
||||
else
|
||||
$aad[] = ['next'=>null];
|
||||
}
|
||||
for($i=2;$i<count($aaa)-1;$i++)
|
||||
for($i=1,$cnt=(count($aaa));$i<$cnt;$i++)
|
||||
$aab[] = trim(explode('"', $aaa[$i])[0]);
|
||||
|
||||
if($jsonon)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
include_once '_function.php';
|
||||
$marumaru = new Marumaru();
|
||||
$data = $marumaru->WEBParsing('http://marumaru.in/'.$_GET['href']);
|
||||
$data = $marumaru->WEBParsing('https://marumaru.in/'.$_GET['href']);
|
||||
$data = str_replace('class="con_link" ', 'target="_blank" ', $data);
|
||||
$data = preg_replace('/(<[^>]+) style=".*?"/i', '$1', $data);
|
||||
$thumb = $marumaru->splits($data, '<meta property="og:image" content="', '"');
|
||||
$a = explode('<a target="_blank" href="', $data);
|
||||
for($i=1;$i<count($a);$i++)
|
||||
for($i=1,$cnt=count($a);$i<$cnt;$i++)
|
||||
{
|
||||
$href = explode('/', explode('"', $a[$i])[0])[4];
|
||||
$title = str_replace(' ', ' ', strip_tags('<a target="_blank" href="'.explode('</a>', $a[$i])[0]));
|
||||
if(!$title) continue;
|
||||
$episodes[] = ['href'=>$href, 'title'=>$title];
|
||||
}
|
||||
echo json_encode(array('cover'=>$thumb, 'episodes'=>$episodes));
|
||||
echo json_encode(array('cover'=>$thumb, 'episodes'=>$episodes));
|
||||
+4
-4
@@ -4,19 +4,19 @@
|
||||
$file = $marumaru->FileRead('mangalist.txt');
|
||||
if(!isset($file) || @explode(PHP_EOL, $file)[0] < time())
|
||||
{
|
||||
$data = $marumaru->WEBParsing('http://marumaru.in/c/1');
|
||||
$data = $marumaru->WEBParsing('https://marumaru.in/c/53');
|
||||
$a = explode('" href="/b/manga/', $data);
|
||||
$b = explode('<div width="200"><', $data);
|
||||
for($i=1;$i<count($a);$i++)
|
||||
for($i=1,$cnt=count($a);$i<$cnt;$i++)
|
||||
{
|
||||
$name = strip_tags('<'.explode('</div>', $b[$i])[0]);
|
||||
$id = explode('"', $a[$i])[0];
|
||||
$c[] = ['href'=>'/b/manga/'.$id, 'title'=>$name, 'id'=>$id];
|
||||
}
|
||||
$file = json_encode(array('list'=>$c));
|
||||
$marumaru->FileWrite($file, 'mangalist.txt');
|
||||
$marumaru->FileWrite($file, 'mangalist.txt', (60*30));
|
||||
echo $file;
|
||||
exit;
|
||||
}
|
||||
echo explode(PHP_EOL, $file)[1];
|
||||
exit;
|
||||
exit;
|
||||
Reference in New Issue
Block a user