<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ use App\Model\Crawl; use App\Model\DmmList; Route::get('/', function () { $crawls = Crawl::orderBy('status', 'desc')->orderBy('id', 'desc')->get(); return view('welcome', ['crawls' => $crawls]); }); Route::get('/go/{id}', function ($id) { $crawl = Crawl::find($id); if ($crawl) { $crawl->status = Crawl::DISABLE; $crawl->save(); return redirect("http://extratorrent.cc{$crawl->href}"); } return response('id not found'); }); Route::get('/dmm', function () { $dmms = DmmList::orderBy('id', 'desc')->get(); return view('dmm', ['dmms' => $dmms]); });
public function handle() { $this->jobLogInfo('crawl start'); $crawler = new Crawler(); $guzzle = new Guzzle(['timeout' => 10, 'cookies' => true]); $jar = new CookieJar(); $guzzle->get('http://extratorrent.cc/login/', ['cookies' => $jar])->getBody(); $guzzle->post('http://extratorrent.cc/login/', ['cookies' => $jar, 'form_params' => ['login' => 'sdhou', 'password' => '302282', 'x' => 0, 'y' => 0]])->getBody(); $html = $guzzle->get('http://extratorrent.cc/category/552/Video+Torrents.html?srt=seeds&order=desc&pp=100', ['cookies' => $jar])->getBody(); $crawler->addHtmlContent($html); $crawler->filterXPath('//table[@class="tl"]//td[@class="tli"]/a')->each(function (Crawler $crawle) { $title = $crawle->text(); $href = $crawle->attr('href'); if (!$title) { return; } if (\App\Model\Crawl::whereHref($href)->first()) { return; } \App\Model\Crawl::add($title, $href); $this->jobLogInfo("add: {$title}"); }); $this->jobLogInfo('crawl end'); }