1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * Created by PhpStorm.
- * User: tandunzhao
- * Date: 2017/11/24
- * Time: 上午11:48
- */
- namespace App\Console\Commands;
- use Log;
- use App\Modules\Finance\Models\Bill;
- use GuzzleHttp;
- use Illuminate\Console\Command;
- use Storage;
- class DownPic extends Command
- {
- /**
- * 执行命令 php artisan bill_task
- *
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'down_pic';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '下载图片';
- public function handle() {
- $client = new GuzzleHttp\Client();
- $fp = fopen(storage_path("app/abc.txt"), 'r');
- $str = fread($fp,filesize(storage_path("app/abc.txt")));
- $arraylist= explode("\n",$str);
- for($i=0;$i<count($arraylist);$i++) //把它们全部输出来
- {
- if(!empty($arraylist[$i])) {
- echo $arraylist[$i]." \n";
- $data = $client->request('GET', $arraylist[$i])->getBody()->getContents();
- $filename = str_replace("http://cdn-novel.weituibao.com/", "", $arraylist[$i]);
- echo $filename." \n";
- Storage::disk('local')->put($filename, $data);
- }
- }
- }
- }
|