diff --git a/Cinema/Common.php b/Cinema/Common.php index 1c77e03..5d743c0 100644 --- a/Cinema/Common.php +++ b/Cinema/Common.php @@ -5,14 +5,16 @@ * Date: 2017/12/6 * Time: 13:12 */ + namespace Cinema; include_once('Spider.php'); class Common { - public static function getHeader(){ - $defaultSearch = Spider::searchHistory(1); + public static function getHeader() + { + $defaultSearch = Spider::getHistory(1); return $header = ""; } - public static $footer = "

© Copyright lifanko 2017 December

"; - public static $QQGroup = "

点击加入【意见建议】&【问题反馈】&【爬虫技术】交流群:567051081

"; + + public static $footer = "

Copyright © lifanko 2017-2018 豫ICP备16040860号-1

"; } \ No newline at end of file diff --git a/Cinema/Spider.php b/Cinema/Spider.php index c385bd9..05c1813 100644 --- a/Cinema/Spider.php +++ b/Cinema/Spider.php @@ -262,11 +262,16 @@ public static function saveInfo($dir, $new = '') if (file_exists($filePath)) { if (empty($new)) { //$new为空时是读取状态,不为空时为写入状态 - $fp = fopen($filePath, "r"); - $str = fread($fp, filesize($filePath)); //指定读取大小,这里把整个文件内容读取出来 - fclose($fp); + //文件不为空时返回文件内容,为空时返回json格式的空 + if(filesize($filePath)){ + $fp = fopen($filePath, "r"); + $fJson = fread($fp, filesize($filePath)); //指定读取大小,这里把整个文件内容读取出来 + fclose($fp); + }else{ + $fJson = '{}'; + } - return $str; + return $fJson; } else { $fp = fopen($filePath, "w"); flock($fp, LOCK_EX); @@ -277,12 +282,13 @@ public static function saveInfo($dir, $new = '') return true; } } + return false; } - public static function searchHistory($max = 10) + public static function getHistory($max = 10, $dir = 'searchHistory') { - $jsonHotSearch = self::saveInfo('searchHistory'); + $jsonHotSearch = self::saveInfo($dir); if (!empty($jsonHotSearch)) { $arrHotSearch = json_decode($jsonHotSearch, true); //解析为数组格式 @@ -311,6 +317,26 @@ public static function searchHistory($max = 10) return ''; } + public static function clickRec($dir, $name){ + $jsonRes = self::saveInfo($dir); + + if (!empty($jsonRes)) { + $arrRes = json_decode($jsonRes, true); //解析为数组格式 + if (array_key_exists($name, $arrRes)) { //有记录则加一 + $arrRes[$name] += 1; + } else { //无记录则在数组中创建 + $arrRes[$name] = 1; + } + + $jsonRes = json_encode($arrRes); + } else { //文件为空 + $arrRes = [$name => 1]; + $jsonRes = json_encode($arrRes); + } + + self::saveInfo($dir, $jsonRes); + } + public static $parser = "
diff --git a/Cinema/clickHistory.txt b/Cinema/clickHistory.txt new file mode 100644 index 0000000..e69de29 diff --git a/Cinema/defaultSearch.txt b/Cinema/defaultSearch.txt index 0637a08..e69de29 100644 --- a/Cinema/defaultSearch.txt +++ b/Cinema/defaultSearch.txt @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/Cinema/searchHistory.txt b/Cinema/searchHistory.txt index 0424519..e69de29 100644 --- a/Cinema/searchHistory.txt +++ b/Cinema/searchHistory.txt @@ -1 +0,0 @@ -{"\u7231\u60c5\u516c\u5bd3":4,"\u6b4c\u624b":2,"\u5929\u5929\u5411\u4e0a":6,"\u5feb\u4e50\u5927\u672c\u8425":2,"\u7f8e\u4e3d\u7684\u5927\u811a":2,"\u7231\u60c5":1,"\u7231\u60c5\u516c\u5bd34":2,"\u7f8e\u4e3d\u7684\u5927":1,"\u7f8e\u4e3d":6} \ No newline at end of file diff --git a/README.md b/README.md index 92b4625..de79eea 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ http://ali.lifanko.cn/video/ + Auto Crawling & Update + Play History Memory + No Register / No Sign In / No AD - + Search recommend / Search History - + Windows & Linus Server Auto Fit + + Search recommend / Search History / Click History + + Windows & Linus Server Auto Suit ### Server PHP7 + Apache/2.4.6 (CentOS) diff --git a/hotSearch.php b/hotSearch.php index 5342132..aaef2a3 100644 --- a/hotSearch.php +++ b/hotSearch.php @@ -27,8 +27,8 @@ function __autoload($class) include_once('Cinema/Common.php'); } -if (empty($_GET['max'])) { //显示的关键词数量,默认最多显示99个 - $max = 99; +if (empty($_GET['max'])) { //显示的关键词数量,默认最多显示50个 + $max = 50; } ?> @@ -90,7 +90,16 @@ function __autoload($class)
+
+
+

点击量排行榜:

+
+
diff --git a/loading.html b/loading.html index 1f131a4..55f75fd 100644 --- a/loading.html +++ b/loading.html @@ -14,33 +14,11 @@ -

-

影视爬虫 - -

-

-
-赞赏:在GitHub上送我一颗小星星 -

-木然云:科学上网超稳定 -

点击左上方“立即播放”即可播放影片(如果播放不了可以试下不同的解析器)

+

+

影视爬虫(v2.2)

+

广告:科学上网工具

+

木然云:超快超稳定(略贵,用了一段时间用不起了)

+

加速度:速度较慢但查资料足够,科学上网15天仅需¥2(推荐)

+

电影请点击左上方“立即播放”、电视剧选集后即可播放
(播放不了请尝试切换下方的解析器)

\ No newline at end of file diff --git a/play.php b/play.php index 8c35a69..c08022c 100644 --- a/play.php +++ b/play.php @@ -152,6 +152,9 @@ function __autoload($class) if(empty($sets)){ echo '《' . $name . '》—— 暂无播放资源'; }else{ + //如果有播放资源,则点击量加一 + Spider::clickRec('clickHistory', $name); + echo '《' . $name . '》—— 总' . count($sets[3]) . '集