Skip to content

Commit

Permalink
Fixed MovieCat & Add DESCRIPTION+KEYWORDS & Modify Style & Modify Sou…
Browse files Browse the repository at this point in the history
…rce To HTTPS
  • Loading branch information
lifankohome committed Oct 7, 2018
1 parent d08b1aa commit c115076
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 26 deletions.
52 changes: 40 additions & 12 deletions Cinema/Spider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +42,7 @@ public static function getMovies($cat = 'all', $page = 1)
$movieImgDom = '#<div class="cover g-playicon">
<img src="(.*?)">#';
$movieCatDom = '#<a class="js-tongjip" href="https://www.360kan.com/dianying/list.php\?year=all\&area=all\&act=all\&cat=(.*?)" target="_self">(.*?)\s+(<i class="s-hot-icon"><\/i>\s+){0,1}<\/a>#';
$presentCatDom = '#<b class="on">(.*?)</b>#';

preg_match_all($movieNameDom, $dom, $movieName);
preg_match_all($movieScoreDom, $dom, $movieScore);
Expand All @@ -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) {
Expand All @@ -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;
Expand All @@ -79,22 +97,26 @@ 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 = '#<span class="s1">(.*?)</span>#';
$tvLinkDom = '#<a class="js-tongjic" href="(.*?)">#';
$tvActorDom = '# <p class="star">(.*?)</p>#';
$tvImgDom = '#<div class="cover g-playicon">
<img src="(.*?)">#';
$tvUpdateDom = '#<span class="hint">(.*?)</span> #';
$tvCatDom = '#<a class="js-tongjip" href="http://www.360kan.com/dianshi/list.php\?year=all\&area\=all\&act\=all\&cat\=(.*?)" target="_self">(.*?)</a>#';
$tvCatDom = '#<a class="js-tongjip" href="https://www.360kan.com/dianshi/list.php\?year=all\&area\=all\&act\=all\&cat\=(.*?)" target="_self">(.*?)\s+(<i class="s-hot-icon"><\/i>\s+){0,1}<\/a>#';
$presentCatDom = '#<b class="on">(.*?)</b>#';

preg_match_all($tvLinkDom, $dom, $tvLink);
preg_match_all($tvNameDom, $dom, $tvName);
preg_match_all($tvImgDom, $dom, $tvImg);
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) {
Expand All @@ -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;
Expand All @@ -134,22 +159,26 @@ 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 = '#<span class="s1">(.*?)</span>#';
$varietyLinkDom = '#<a class="js-tongjic" href="(.*?)">#';
$varietyActorDom = '# <p class="star">(.*?)</p>#';
$varietyImgDom = '#<div class="cover g-playicon">
<img src="(.*?)">#';
$varietyUpdateDom = '#<span class="hint">(.*?)</span> #';
$varietyCatDom = '#<a class="js-tongjip" href="http://www.360kan.com/zongyi/list\?act\=all\&area\=all\&cat\=(.*?)" target="_self">(.*?)</a>#';
$varietyCatDom = '#<a class="js-tongjip" href="https://www.360kan.com/zongyi/list\?act\=all\&area\=all\&cat\=(.*?)" target="_self">(.*?)\s+(<i class="s-hot-icon"><\/i>\s+){0,1}<\/a>#';
$presentCatDom = '#<b class="on">(.*?)</b>#';

preg_match_all($varietyLinkDom, $dom, $varietyLink);
preg_match_all($varietyNameDom, $dom, $varietyName);
preg_match_all($varietyImgDom, $dom, $varietyImg);
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) {
Expand All @@ -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);
Expand Down Expand Up @@ -315,8 +345,6 @@ public static function getHistory($max = 10, $dir = 'searchHistory')
} else { //文件为空
return "<li><a>数据为空</a></li>";
}

return '';
}

public static function clickRec($dir, $name)
Expand Down
10 changes: 10 additions & 0 deletions css/teleplay.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions css/variety.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"}';

?>
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -75,7 +72,7 @@ function __autoload($class)
if ($cat == 'all') {
echo '热门电影推荐';
} else {
echo '当前分类:' . json_decode($catDir, true)[$cat];
echo '当前分类:' . Spider::getPresentCat();
}
?>
</h3>
Expand Down
7 changes: 2 additions & 5 deletions teleplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"}';

?>
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -72,9 +69,9 @@ function __autoload($class)
<h3>
<?php
if ($cat == 'all') {
echo '热门电视剧';
echo '热门电视剧推荐';
} else {
echo '当前分类:' . json_decode($catDir, true)[$cat];
echo '当前分类:' . Spider::getPresentCat();
}
?>
</h3>
Expand Down
7 changes: 2 additions & 5 deletions variety.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"}';

?>
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -72,9 +69,9 @@ function __autoload($class)
<h3>
<?php
if ($cat == 'all') {
echo '热门综艺';
echo '热门综艺推荐';
} else {
echo '当前分类:' . json_decode($catDir, true)[$cat];
echo '当前分类:' . Spider::getPresentCat();
}
?>
</h3>
Expand Down

0 comments on commit c115076

Please sign in to comment.