예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $client = new \Goutte\Client();
     foreach (\MkmScraper\Card::all() as $card) {
         if (\MkmScraper\GraphPrice::where("id_card", $card->id)->where("created_at", ">", date('Y-m-d H:i:s', strtotime('-1 week')))->count() < 1) {
             $crawler = $client->request('GET', 'https://www.magiccardmarket.eu/Products/Singles/' . rawurlencode($card->set) . '/' . rawurlencode($card->name));
             $available = $crawler->filter('#ProductInformation script')->first()->text();
             $split = explode("chartData =", $available);
             $split2 = explode(";var ctx", $split[1]);
             $object = json_decode($split2[0]);
             $count = 0;
             foreach ($object->labels as $key => $label) {
                 if (\MkmScraper\GraphPrice::where("id_card", $card->id)->where("date", date_format(date_create_from_format('d.m.y', $label), 'Y-m-d'))->count() < 1) {
                     \MkmScraper\GraphPrice::create(array("id_card" => $card->id, "date" => date_format(date_create_from_format('d.m.y', $label), 'Y-m-d'), "sell" => $object->datasets[0]->data[$key]));
                     $count++;
                 }
             }
             if ($count == 0) {
                 \MkmScraper\GraphPrice::create(array("id_card" => $card->id, "date" => "0000-00-00", "sell" => ''));
             }
             print $card->name . "\n";
         }
     }
 }
예제 #2
0
 public function exportAllNew()
 {
     $filename = "export.arff";
     $handle = fopen($filename, 'w+');
     $text = "@relation 'price'\n@attribute y {-1,1}\n@attribute x0 numeric\n@data\n\n";
     $array = array(array());
     foreach (\MkmScraper\Card::where("rarity", "Mythic")->get() as $card) {
         $date = "2015-09-03";
         while ($date < "2015-12-10") {
             $row = array();
             //$objects['sell'][]=array($dateexp[0], $dateexp[1],$dateexp[2],\MkmScraper\GraphPrice::getPriceWeek($date,$this));
             //$objects['art'][]=array($dateexp[0], $dateexp[1],$dateexp[2],\MkmScraper\Article::getArticlesWeek($date,$this));
             $articles = \MkmScraper\Article::getDiffWeek(date("Y-m-d", strtotime($date) + 21 * 24 * 60 * 60), $card);
             if ($articles > 0) {
                 $row[] = \MkmScraper\DecklistAppearance::tournamentDiffLastWeek($date, $card);
                 $row[] = \MkmScraper\GraphPrice::getPriceDiffWeekBoolean($date, $card);
                 $row[] = $articles;
                 $array[] = $row;
             }
             //$objects['art'][]=array($dateexp[0], $dateexp[1],$dateexp[2],\MkmScraper\Article::getDiffWeek($date,$this));
             $date = date("Y-m-d", strtotime($date) + 7 * 24 * 60 * 60);
         }
     }
     foreach ($array as $row) {
         foreach ($row as $item) {
             $text .= $item . ",";
         }
         $text .= "\n";
     }
     file_put_contents($filename, $text);
     return \Response::download($filename, 'export.arff', array('Content-Type' => 'text/aarf'));
 }
예제 #3
0
            });
        }
    });
});
Route::get("htmlscrape", function () {
    $client = new \Goutte\Client();
    foreach (\MkmScraper\Card::all() as $card) {
        $time = microtime();
        $crawler = $client->request('GET', 'https://www.magiccardmarket.eu/Products/Singles/' . rawurlencode($card->set) . '/' . rawurlencode($card->name));
        $available = $crawler->filter('#ProductInformation script')->first()->text();
        $split = explode("chartData =", $available);
        $split2 = explode(";var ctx", $split[1]);
        $object = json_decode($split2[0]);
        foreach ($object->labels as $key => $label) {
            if (\MkmScraper\GraphPrice::where("id_card", $card->id)->where("date", date_format(date_create_from_format('d.m.y', $label), 'Y-m-d'))->count() < 1) {
                \MkmScraper\GraphPrice::create(array("id_card" => $card->id, "date" => date_format(date_create_from_format('d.m.y', $label), 'Y-m-d'), "sell" => $object->datasets[0]->data[$key]));
            }
        }
        print $card->name . " - " . (microtime() - $time) . " ms </br>";
    }
});
Route::get("decklists/wizards", function () {
    return view("decklists/wizards");
});
Route::post("decklists/wizards", "ScrapeController@processWizards");
Route::get("decklists/scg", function () {
    return view("decklists/scg");
});
Route::post("decklists/scg", "ScrapeController@processScg");
Route::get("decklists/top8", function () {
    return view("decklists/top8");
예제 #4
0
파일: Card.php 프로젝트: neyko5/mkmscraper
 public function getMovementData()
 {
     $date = "2015-09-03";
     $objects = array();
     while ($date < "2015-12-10") {
         //$object['sell']=\MkmScraper\CardPrice::getPriceWeek($date,$this);
         $object['price'] = \MkmScraper\GraphPrice::getPriceWeek($date, $this);
         $object['lowprice'] = \MkmScraper\CardPrice::getPriceWeek($date, $this);
         $object['singleprice'] = \MkmScraper\GraphPrice::getPriceSingleWeek($date, $this);
         $object['lowsingleprice'] = \MkmScraper\CardPrice::getPriceSingleWeek($date, $this);
         //$object['art']=\MkmScraper\Article::getArticlesWeek($date,$this);
         //$object['art']=\MkmScraper\Article::getArticlesWeek(date("Y-m-d",strtotime($date)+6*24*60*60),$this);
         //$object['art']=\MkmScraper\Article::getArticlesTwoWeek($date,$this);
         $object['sell'] = \MkmScraper\GraphPrice::getPriceDiffWeek($date, $this);
         $object['date'] = $date;
         //$object['sell']=\MkmScraper\CardPrice::getPriceDiffWeek($date,$this);
         //$objects['art'][]=array($dateexp[0], $dateexp[1],$dateexp[2],\MkmScraper\Article::getDiffWeek($date,$this));
         $object['arttot'] = \MkmScraper\Article::getArticlesWeek($date, $this);
         $object['art'] = \MkmScraper\Article::getDiffWeek($date, $this);
         $object['tour'] = \MkmScraper\DecklistAppearance::tournamentLastWeek($date, $this);
         $object['tourdiff'] = \MkmScraper\DecklistAppearance::tournamentDiffLastWeek(date("Y-m-d", strtotime($date) - 14 * 24 * 60 * 60), $this);
         $date = date("Y-m-d", strtotime($date) + 7 * 24 * 60 * 60);
         $objects[] = $object;
     }
     return $objects;
 }
예제 #5
0
 public static function getPriceSingleWeekBoolean($date, $card)
 {
     return GraphPrice::getPriceSingleWeek($date, $card) > 0 ? "1" : "-1";
 }
예제 #6
0
 public static function getPriceDiffWeekBoolean($date, $card)
 {
     return \Mkmscraper\GraphPrice::getPriceDiffWeek($date, $card) > 0 ? "A" : "B";
 }