Directly on the code, the main function
Ignore_user_abort (TRUE);
This function ignores the terminal being closed (the Open Web page is closed), the back
GetFiles () This function is a custom function that performs the acquisition task, followed by the next path
Open the written page, close, after the discovery of the task can be completed, interested can try.
<?PHP//set ignore whether terminal window is closedIgnore_user_abort(true);Ini_set(' Max_execution_time ', ' 0 ');//Collect page functions, do not understand the implementation of Baidu Curl PHPfunctionGetFiles$url,$name){ $name=$name.". txt; $ch= Curl_init ("$url"); $fp=fopen("$name"," W "); curl_setopt ($ch, Curlopt_file,$fp); curl_setopt ($ch, Curlopt_header, 0); Curl_exec ($ch); Curl_close ($ch); fclose($fp); Sleep(5); Echo' <script>window.close ();</script> ';}//Configure an array of page paths to be collected$urls=Array( ' http://www.cnblogs.com/jianqingwang/p/6373168.html ', ' http://www.cnblogs.com/jianqingwang/p/6148644.html ', ' Http://www.61916.com/news_view_2423.html ', ' http://blog.sina.com.cn/s/blog_8e326c350102w1ah.html ', ' HTTP// Www.w3school.com.cn/php/func_misc_ignore_user_abort.asp ', ' http://xinwen.eastday.com/a/170219205305597.html ', ' Http://society.huanqiu.com/article/2017-02/10162630.html?from=bdwz ', ' http://www.cankaoxiaoxi.com/roll10/bd/ 20170220/1699670.shtml ', ' http://news.china.com/socialgd/10000169/20170220/30266284.html ', ' http://news.k618.cn/ Society/201702/t20170220_10368740.html ', ' http://fj.qq.com/a/20170218/029521.htm ');//iterating through an arrayforeach($urls as $key=$val) {GetFiles ($val,$key);}?>
PHP work notes: Perform PHP tasks offline