/** * Execute the console command. * * @return mixed */ public function handle() { $client = new \Goutte\Client(); foreach (\MkmScraper\Card::all() as $card) { if ($card->todaysPrice()->count() < 1) { $crawler = $client->request('GET', 'https://www.magiccardmarket.eu/Products/Singles/' . rawurlencode($card->set) . '/' . rawurlencode($card->name)); \Log::info('https://www.magiccardmarket.eu/Products/Singles/' . rawurlencode($card->set) . '/' . rawurlencode($card->name)); $available = 0; $lowfinal = 0; $trendfinal = 0; try { if ($av = $crawler->filter('.sectioncontent .availTable .row_0 .cell_0_1')->first()) { $available = $av->text(); } if ($lo = $crawler->filter('.sectioncontent .availTable .row_1 .cell_1_1 span')->first()) { $low = $lo->text(); $lowfinal = str_replace(",", ".", $low); } if ($tr = $crawler->filter('.sectioncontent .availTable .row_2 .cell_2_1')->first()) { $trend = $tr->text(); $trendnumber = explode(" ", $trend); $trendfinal = str_replace(",", ".", $trendnumber[0]); } } catch (Exception $e) { print $e->getMessage(); } $cardPrice = \MkmScraper\CardPrice::create(array("id_card" => $card->id, "low" => $lowfinal, "trend" => $trendfinal, "sellers" => $available)); } } }
/** * Execute the console command. * * @return mixed */ public function handle() { foreach (\MkmScraper\Card::all() as $card) { $product = queryMKMAPI("product/" . $card->id); $articles = queryMKMAPI("articles/" . $card->id); $price = $product->product->priceGuide; $cardPrice = \MkmScraper\CardPrice::create(array("id_card" => $card->id, "sell" => $price->SELL, "low" => $price->LOW, "lowex" => $price->LOWEX, "lowfoil" => $price->LOWFOIL, "avg" => $price->AVG, "trend" => $price->TREND, "sellers" => sizeof($articles->article))); } }