Beispiel #1
0
 public function handle()
 {
     $this->jobLogInfo('dmm start');
     $crawler = new Crawler();
     $guzzle = new Guzzle(['timeout' => 10, 'cookies' => true]);
     $jar = new CookieJar();
     \App\Model\Dmm::all()->map(function ($dmm) use($guzzle, $jar, $crawler) {
         $html = $guzzle->get($dmm->href, ['cookies' => $jar])->getBody();
         $crawler->addHtmlContent($html);
         $crawler->filterXPath('//ul[@id="list"]/li/div[1]//p[@class="tmb"]/a')->each(function (Crawler $crawle) use($dmm) {
             $title = trim($crawle->text());
             $href = $crawle->attr('href');
             $img_url = $crawle->filterXPath('//span[1]/img')->attr('src');
             DmmList::add($dmm->id, $title, $href, $img_url);
             echo "{$href}\n";
         });
         $crawler->clear();
     });
     $this->jobLogInfo('crawl end');
 }
Beispiel #2
0
<?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]);
});