diff --git a/Cinema/Spider.php b/Cinema/Spider.php index 49b4cbb..fa418be 100644 --- a/Cinema/Spider.php +++ b/Cinema/Spider.php @@ -13,6 +13,17 @@ class Spider private static $moviesCat = array(); private static $tvCat = array(); private static $varietyCat = array(); + private static $presentCat = ''; + + public static function getPresentCat() + { + return self::$presentCat; + } + + private static function setPresentCat($presentCat) + { + self::$presentCat = $presentCat; + } /** * @param string $cat @@ -31,6 +42,7 @@ public static function getMovies($cat = 'all', $page = 1) $movieImgDom = '#
#'; $movieCatDom = '#(.*?)\s+(<\/i>\s+){0,1}<\/a>#'; + $presentCatDom = '#(.*?)#'; preg_match_all($movieNameDom, $dom, $movieName); preg_match_all($movieScoreDom, $dom, $movieScore); @@ -39,6 +51,9 @@ public static function getMovies($cat = 'all', $page = 1) preg_match_all($movieActorDom, $dom, $movieActor); preg_match_all($movieImgDom, $dom, $movieImg); preg_match_all($movieCatDom, $dom, $movieCat); + preg_match_all($presentCatDom, $dom, $presentCat); + + self::setPresentCat($presentCat[1][0]); $movies = array(); foreach ($movieName[1] as $key => $value) { @@ -57,6 +72,9 @@ public static function getMovies($cat = 'all', $page = 1) $movieCatArr[$val] = $movieCat[2][$key]; } + //为了页面美观,仅保留显示前20个分类 + $movieCatArr = array_slice($movieCatArr, 0, 20, true); + self::setMoviesCat($movieCatArr); return $movies; @@ -79,7 +97,7 @@ private static function setMoviesCat($moviesCat) */ public static function getTvs($cat = 'all', $page = 1) { - $dom = file_get_contents('http://www.360kan.com/dianshi/list.php?year=all&area=all&act=all&cat=' . $cat . '&pageno=' . $page); + $dom = file_get_contents('https://www.360kan.com/dianshi/list.php?year=all&area=all&act=all&cat=' . $cat . '&pageno=' . $page); $tvNameDom = '#(.*?)#'; $tvLinkDom = '##'; @@ -87,7 +105,8 @@ public static function getTvs($cat = 'all', $page = 1) $tvImgDom = '#
#'; $tvUpdateDom = '#(.*?) #'; - $tvCatDom = '#(.*?)#'; + $tvCatDom = '#(.*?)\s+(<\/i>\s+){0,1}<\/a>#'; + $presentCatDom = '#(.*?)#'; preg_match_all($tvLinkDom, $dom, $tvLink); preg_match_all($tvNameDom, $dom, $tvName); @@ -95,6 +114,9 @@ public static function getTvs($cat = 'all', $page = 1) preg_match_all($tvActorDom, $dom, $tvActor); preg_match_all($tvUpdateDom, $dom, $tvUpdate); preg_match_all($tvCatDom, $dom, $tvCat); + preg_match_all($presentCatDom, $dom, $presentCat); + + self::setPresentCat($presentCat[1][0]); $teleplays = array(); foreach ($tvName[1] as $key => $value) { @@ -108,10 +130,13 @@ public static function getTvs($cat = 'all', $page = 1) } $tvCatArr = array(); - foreach ($tvCat[2] as $key => $val) { - $tvCatArr[$tvCat[1][$key]] = $val; + foreach ($tvCat[1] as $key => $val) { + $tvCatArr[$val] = $tvCat[2][$key]; } + //为了页面美观,仅保留显示前20个分类 + $tvCatArr = array_slice($tvCatArr, 0, 20, true); + self::setTvCat($tvCatArr); return $teleplays; @@ -134,7 +159,7 @@ private static function setTvCat($tvCat) */ public static function getVarieties($cat = 'all', $page = 1) { - $dom = file_get_contents('http://www.360kan.com/zongyi/list?act=all&area=all&cat=' . $cat . '&pageno=' . $page); + $dom = file_get_contents('https://www.360kan.com/zongyi/list?act=all&area=all&cat=' . $cat . '&pageno=' . $page); $varietyNameDom = '#(.*?)#'; $varietyLinkDom = '##'; @@ -142,7 +167,8 @@ public static function getVarieties($cat = 'all', $page = 1) $varietyImgDom = '#
#'; $varietyUpdateDom = '#(.*?) #'; - $varietyCatDom = '#(.*?)#'; + $varietyCatDom = '#(.*?)\s+(<\/i>\s+){0,1}<\/a>#'; + $presentCatDom = '#(.*?)#'; preg_match_all($varietyLinkDom, $dom, $varietyLink); preg_match_all($varietyNameDom, $dom, $varietyName); @@ -150,6 +176,9 @@ public static function getVarieties($cat = 'all', $page = 1) preg_match_all($varietyActorDom, $dom, $varietyActor); preg_match_all($varietyUpdateDom, $dom, $varietyUpdate); preg_match_all($varietyCatDom, $dom, $varietyCat); + preg_match_all($presentCatDom, $dom, $presentCat); + + self::setPresentCat($presentCat[1][0]); $teleplays = array(); foreach ($varietyName[1] as $key => $value) { @@ -162,11 +191,12 @@ public static function getVarieties($cat = 'all', $page = 1) $teleplays[$key] = $buffer; } - array_pop($varietyCat[2]); //最后一个元素是【真人秀】,只有这一个分类是三个字,影响排版,所以去掉不要 - $varietyCatArr = array(); - foreach ($varietyCat[2] as $key => $val) { - $varietyCatArr[$varietyCat[1][$key]] = $val; + foreach ($varietyCat[1] as $key => $val) { + //为了页面美观,仅保留分类长度为2个字的综艺 + if (mb_strlen($varietyCat[2][$key]) <= 2) { + $varietyCatArr[$val] = $varietyCat[2][$key]; + } } self::setVarietyCat($varietyCatArr); @@ -315,8 +345,6 @@ public static function getHistory($max = 10, $dir = 'searchHistory') } else { //文件为空 return "
  • 数据为空
  • "; } - - return ''; } public static function clickRec($dir, $name) diff --git a/css/teleplay.css b/css/teleplay.css index 03ebab6..48c93dc 100644 --- a/css/teleplay.css +++ b/css/teleplay.css @@ -17,6 +17,16 @@ body { text-align: center; } +.cat ul li:first-child { + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; +} + +.cat ul li:last-child { + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; +} + .cat ul li a { color: #ff6d70; font-weight: bold; diff --git a/css/variety.css b/css/variety.css index 03ebab6..48c93dc 100644 --- a/css/variety.css +++ b/css/variety.css @@ -17,6 +17,16 @@ body { text-align: center; } +.cat ul li:first-child { + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; +} + +.cat ul li:last-child { + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; +} + .cat ul li a { color: #ff6d70; font-weight: bold; diff --git a/index.php b/index.php index b527b3d..8841369 100644 --- a/index.php +++ b/index.php @@ -35,9 +35,6 @@ function __autoload($class) $movies = Spider::getMovies($cat); $moviesCat = Spider::getMoviesCat(); - -$catDir = '{"103":"\u559c\u5267","100":"\u7231\u60c5","106":"\u52a8\u4f5c","102":"\u6050\u6016","104":"\u79d1\u5e7b","112":"\u5267\u60c5","105":"\u72af\u7f6a","113":"\u5947\u5e7b","108":"\u6218\u4e89","115":"\u60ac\u7591","107":"\u52a8\u753b","117":"\u6587\u827a","101":"\u4f26\u7406","118":"\u7eaa\u5f55","119":"\u4f20\u8bb0","120":"\u6b4c\u821e","121":"\u53e4\u88c5","122":"\u5386\u53f2","123":"\u60ca\u609a","other":"\u5176\u4ed6"}'; - ?> @@ -75,7 +72,7 @@ function __autoload($class) if ($cat == 'all') { echo '热门电影推荐'; } else { - echo '当前分类:' . json_decode($catDir, true)[$cat]; + echo '当前分类:' . Spider::getPresentCat(); } ?> diff --git a/teleplay.php b/teleplay.php index 54ae5ab..b935cde 100644 --- a/teleplay.php +++ b/teleplay.php @@ -34,9 +34,6 @@ function __autoload($class) $teleplays = Spider::getTvs($cat); $tvCat = Spider::getTvCat(); - -$catDir = '{"101":"\u8a00\u60c5","105":"\u4f26\u7406","109":"\u559c\u5267","108":"\u60ac\u7591","111":"\u90fd\u5e02","100":"\u5076\u50cf","104":"\u53e4\u88c5","107":"\u519b\u4e8b","103":"\u8b66\u532a","112":"\u5386\u53f2","106":"\u6b66\u4fa0","113":"\u79d1\u5e7b","102":"\u5bab\u5ef7","114":"\u60c5\u666f","115":"\u52a8\u4f5c","116":"\u52b1\u5fd7","117":"\u795e\u8bdd","118":"\u8c0d\u6218","110":"\u7ca4\u8bed","other":"\u5176\u4ed6"}'; - ?> @@ -72,9 +69,9 @@ function __autoload($class)

    diff --git a/variety.php b/variety.php index 2fb710a..733bbff 100644 --- a/variety.php +++ b/variety.php @@ -34,9 +34,6 @@ function __autoload($class) $varieties = Spider::getVarieties($cat); $varietyCat = Spider::getVarietyCat(); - -$catDir = '{"101":"\u9009\u79c0","102":"\u516b\u5366","103":"\u8bbf\u8c08","104":"\u60c5\u611f","105":"\u751f\u6d3b","106":"\u665a\u4f1a","107":"\u641e\u7b11","108":"\u97f3\u4e50","109":"\u65f6\u5c1a","110":"\u6e38\u620f","111":"\u5c11\u513f","112":"\u4f53\u80b2","113":"\u7eaa\u5b9e","114":"\u79d1\u6559","115":"\u66f2\u827a","116":"\u6b4c\u821e","117":"\u8d22\u7ecf","118":"\u6c7d\u8f66","119":"\u64ad\u62a5","other":"\u5176\u4ed6"}'; - ?> @@ -72,9 +69,9 @@ function __autoload($class)