Beispiel #1
0
 public function processAll()
 {
     $client = new \Goutte\Client();
     foreach (\MkmScraper\Event::all() as $event) {
         $crawler = $client->request('GET', $event->link);
         $i = 1;
         $link = $crawler->filter("td>div>div a")->each(function ($node) use($client, $event, &$i) {
             if (strpos($node->attr('href'), "event") !== false) {
                 $dlcrawler = $client->request('GET', $node->attr('href'));
                 $link = $dlcrawler->filter("table table td .chosen_tr,table table td .hover_tr")->each(function ($node) use($event, $i) {
                     $split = explode(" ", $node->text(), 2);
                     $card = \MkmScraper\Card::where("name", "LIKE", $split[1] . "%")->first();
                     if ($card) {
                         \MkmScraper\DecklistAppearance::create(array("id_card" => $card->id, "number" => $split[0], "place" => $i, "id_event" => $event->id));
                         //print $card->id." - ".$node->text()."<br/>";
                     }
                 });
                 $i = $i + 1;
             }
         });
     }
 }
 public static function tournamentDiffLastWeekBoolean($date, $card)
 {
     return DecklistAppearance::tournamentDiffLastWeek($date, $card) >= 0 ? "1" : "-1";
 }
Beispiel #3
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'));
 }
Beispiel #4
0
 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;
 }