@@ -18,6 +18,8 @@ class Bilibili
1818 "User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36 "
1919 ];//设置用户user-agent
2020
21+ public $ spiderName = "Bilibili " ;
22+
2123 public $ rank_type = [ //排行榜
2224 1 => 'day ' ,
2325 2 => 'month ' ,
@@ -147,32 +149,9 @@ public function getYesterday($date)
147149 return $ yesterday ;
148150 }
149151
150-
151- /**
152- * 输出选择菜单
153- * @param $string
154- * @param $spiderCore
155- */
156- public function menu ($ string , $ spiderCore )
157- {
158- print_r ( //输出用户选择的菜单
159- "============================================ " . PHP_EOL . "
160- \033[33m BIlibili Spider \033[0m " .
161- $ spiderCore ->eol ($ spiderCore ->print_menu ($ string )) .
162- "============================================ " . PHP_EOL
163- );
164- }
165-
166152 /**
167153 * Bilibili 搜索爬虫
168154 * @param $spiderCore
169- * https://api.vc.bilibili.com/link_draw/v1/doc/detail?doc_id=925202 //内容详细
170- * https://api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=photo&highlight=1&keyword=2b&order=totalrank&category_id=1
171- * https://api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=photo&highlight=1&keyword=2b&order=totalrank&category_id=2 摄影
172- * https://api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=photo&highlight=1&keyword=2b&order=pubdate 最新
173- * https://api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=photo&highlight=1&keyword=2b&order=totalrank&category_id=2 默认
174- * https://api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=photo&highlight=1&keyword=2b&order=stow&category_id=1 最多收藏
175- * https://api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=photo&highlight=1&keyword=2b&order=stow&category_id=0 全部
176155 */
177156 public function search ($ spiderCore )
178157 {
@@ -238,7 +217,7 @@ public function search($spiderCore)
238217 */
239218 public function quick_input ($ spiderCore , $ string , $ array , $ exit_string , $ default )
240219 {
241- $ this -> menu ($ array , $ spiderCore );
220+ $ spiderCore -> bMenu ($ array ,$ this -> spiderName );
242221 $ input = $ spiderCore ->user_input ($ string , $ default );
243222 if (@empty ($ array [$ input ])) {
244223 die ($ exit_string );
@@ -307,6 +286,6 @@ public function top50($spiderCore)
307286
308287$ bilibili = new Bilibili ();
309288
310- $ bilibili -> menu ($ bilibili ->mode , $ spiderCore );
289+ $ spiderCore -> bMenu ($ bilibili ->mode ,$ bilibili -> spiderName );
311290$ mode = $ spiderCore ->user_input (PHP_EOL . "请选择你需要使用的模式: " , null );
312291@empty ($ user_mode = $ bilibili ->mode [$ mode ]) ? die (PHP_EOL . '没有这个爬虫模式 ' ) : $ bilibili ->$ user_mode ($ spiderCore ); //调用爬虫,并传入公用function
0 commit comments