@@ -48,21 +48,22 @@ public function get_img_url($result, $spiderCore)
4848 }
4949
5050 //https://www.artstation.com/search/projects.json?direction=desc&order=likes_count&page=1&q=ne&show_pro_first=true
51+
5152 /**
5253 * 图片爬取下载
5354 * @param $spiderCore
5455 * @param $spider_name
5556 * @param $parm
5657 */
57- public function index_spider_core ($ spiderCore , $ spider_name ,$ parm )
58+ public function index_spider_core ($ spiderCore , $ spider_name , $ parm )
5859 {
5960 $ posts_num = $ spiderCore ->user_input ("请输入爬取页数(1页=50个作品)(默认为:1): " , 1 );
6061 for ($ start_num = 1 ; $ start_num <= $ posts_num ; $ start_num ++) {
61- $ url = "https://www.artstation.com/projects.json?page= " . $ start_num. $ parm ;
62+ $ url = "https://www.artstation.com/projects.json?page= " . $ start_num . $ parm ;
6263 $ result = $ spiderCore ->curl_get ($ url , $ this ->userAgent );
6364 $ result = json_decode ($ result );
6465 $ images_arr = $ this ->get_img_url ($ result , $ spiderCore );
65- $ spiderCore ->quick_down_img ($ this ->spider_name . "- " . $ spider_name , $ images_arr );
66+ $ spiderCore ->quick_down_img ($ this ->spider_name . "- " . $ spider_name , $ images_arr, " Artstation " );
6667 $ this ->artatstion_sleep ();//休息一下
6768 }
6869
@@ -74,30 +75,20 @@ public function index_spider_core($spiderCore, $spider_name,$parm)
7475 * @param $spider_name
7576 * @param $parm
7677 */
77- public function search_core ($ spiderCore , $ spider_name ,$ parm )
78+ public function search_core ($ spiderCore , $ spider_name , $ parm )
7879 {
7980 $ posts_num = $ spiderCore ->user_input ("请输入爬取页数(1页=50个作品)(默认为:1): " , 1 );
8081 for ($ start_num = 1 ; $ start_num <= $ posts_num ; $ start_num ++) {
81- $ url = "https://www.artstation.com/search/projects.json?page= " . $ start_num. $ parm ;
82+ $ url = "https://www.artstation.com/search/projects.json?page= " . $ start_num . $ parm ;
8283 $ result = $ spiderCore ->curl_get ($ url , $ this ->userAgent );
8384 $ result = json_decode ($ result );
8485 $ images_arr = $ this ->get_img_url ($ result , $ spiderCore );
85- $ spiderCore ->quick_down_img ($ this ->spider_name . "- " . $ spider_name , $ images_arr );
86- $ this -> artatstion_sleep (); //休息一下
86+ $ spiderCore ->quick_down_img ($ this ->spider_name . "- " . $ spider_name , $ images_arr, " Artstation " );
87+ $ spiderCore -> spider_wait ( ARTSTATION_SLEEP , ARTSTATION_SLEEP_TIME_MIN , ARTSTATION_SLEEP_TIME_MAX );
8788 }
8889
8990 }
9091
91- /**
92- * config设置开启时,每执行一次循环休息一下
93- */
94- public function artatstion_sleep (){
95- if (ARTSTATION_SLEEP ){
96- print_r (PHP_EOL ."爬累了,我要睡觉觉zzzzzzzzzzzzzzz " .PHP_EOL );
97- sleep (ARTSTATION_SLEEP_TIME );
98- }
99- }
100-
10192 /**
10293 * 指定用户爬取
10394 * @param $spiderCore
@@ -109,35 +100,35 @@ public function user($spiderCore)
109100 $ result = json_decode ($ result );
110101
111102 $ images_arr = $ this ->get_img_url ($ result , $ spiderCore );
112- $ spiderCore ->quick_down_img ($ this ->spider_name . "- " . $ user , $ images_arr );
103+ $ spiderCore ->quick_down_img ($ this ->spider_name . "- " . $ user , $ images_arr, " Artstation " , $ user );
113104 }
114105
115106 public function latest ($ spiderCore ) //最新图片
116107 {
117- $ this ->index_spider_core ($ spiderCore , 'latest ' ,'&sorting=latest ' );
108+ $ this ->index_spider_core ($ spiderCore , 'latest ' , '&sorting=latest ' );
118109 }
119110
120111 public function picks ($ spiderCore ) //最佳
121112 {
122- $ this ->index_spider_core ($ spiderCore , 'picks ' ,'&sorting=picks ' );
113+ $ this ->index_spider_core ($ spiderCore , 'picks ' , '&sorting=picks ' );
123114 }
124115
125116 public function trending ($ spiderCore ) //最热门
126117 {
127- $ this ->index_spider_core ($ spiderCore , 'trending ' ,'&sorting=trending ' );
118+ $ this ->index_spider_core ($ spiderCore , 'trending ' , '&sorting=trending ' );
128119 }
129120
130121 //https://www.artstation.com/search/projects.json?direction=desc&order=likes_count&page=1&q=dva&show_pro_first=true
131122 public function search ($ spiderCore )
132123 {
133- $ parm = "" ;
134- $ title = $ spiderCore ->user_input ("请输入要搜索的内容(不填则随缘): " ,RAND_KEYWORD [mt_rand (0 ,count (RAND_KEYWORD )- 1 )]);
135- $ parm .= "&q= " . $ title ;
136- $ show_pro_first= $ spiderCore ->user_input ("请输入True/False " . PHP_EOL . "Pro用户优先?(默认 true): " ,true ) ;
137- $ show_pro_first ==="false " ? $ parm .= "&show_pro_first=false " : $ parm .= "&show_pro_first=true " ;
138- $ order= $ spiderCore ->user_input ("最新还是喜欢?(默认 true 喜欢优先) : " ,true );
139- $ order ==="false " ? $ parm .= "&order=recent " : $ parm .= "&order=likes_count&direction=desc " ;
140- $ this ->search_core ($ spiderCore ,$ title ,$ parm );
124+ $ parm = "" ;
125+ $ title = $ spiderCore ->user_input ("请输入要搜索的内容(不填则随缘): " , RAND_KEYWORD [mt_rand (0 , count (RAND_KEYWORD ) - 1 )]);
126+ $ parm .= "&q= " . $ title ;
127+ $ show_pro_first = $ spiderCore ->user_input ("请输入True/False " . PHP_EOL . "Pro用户优先?(默认 true): " , true );
128+ $ show_pro_first === "false " ? $ parm .= "&show_pro_first=false " : $ parm .= "&show_pro_first=true " ;
129+ $ order = $ spiderCore ->user_input ("最新还是喜欢?(默认 true 喜欢优先) : " , true );
130+ $ order === "false " ? $ parm .= "&order=recent " : $ parm .= "&order=likes_count&direction=desc " ;
131+ $ this ->search_core ($ spiderCore , $ title , $ parm );
141132 }
142133}
143134
0 commit comments