public function processAllArticles() { foreach (\MkmScraper\Article::all() as $article) { $client = new \Goutte\Client(); $crawler = $client->request('GET', $article->link); if ($article->publisher == "1") { $text = $crawler->filter("#article_content")->text(); $title = $crawler->filter("#article_title h2")->text(); $date = $crawler->filter("#article_date")->text(); } if ($article->publisher == "2") { $text = $crawler->filter(".postContent")->text(); $title = $crawler->filter(".postTitle")->text(); $auth = $crawler->filter(".byAuthor")->text(); $au = explode("//", $auth); $date = trim(preg_replace('#[^A-Za-z0-9-, /]#', '', $au[1])); } if ($article->publisher == "3") { $text = $crawler->filter("#blackborder_main_wrapper .content .field-name-body")->text(); echo $text; } if ($article->publisher == "4") { $text = $crawler->filter(".articleBody")->text(); echo $text; } $article->text = $text; $article->title = $title; $article->date = date("Y-m-d", strtotime($date)); $article->save(); } }
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')); }
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; }
public static function getDiffWeekBoolean($date, $card) { return Article::getDiffWeek($date, $card) > 0 ? "1" : "-1"; }