private function crawlYahoo($baseUrl, $kind)
 {
     $today = date('Y-m-d');
     $yesterday = date('Y-m-d', strtotime((date('N') == 1 ? '-3' : '-1') . ' day'));
     //max page
     $html = $this->getHtmlContent($baseUrl . '1');
     preg_match('#<ul class="ymuiPagingBottom.*?</ul>#ms', $html, $matches);
     preg_match_all('#<a.*?>([0-9]+)</a>#ms', $matches[0], $matches);
     $maxPage = $matches[1][count($matches[1]) - 1];
     $order = 0;
     for ($i = 1; $i <= $maxPage; $i++) {
         $html = $this->getHtmlContent($baseUrl . $i);
         preg_match_all('#<tr class="rankingTabledata yjM">.*?</tr>#ms', $html, $matches);
         foreach ($matches[0] as $row) {
             $order++;
             preg_match('#<a.*?>(.*?)</a>#ms', $row, $matchesTemp);
             $issue = Issue::where('code', $matchesTemp[1])->first();
             if (!$issue) {
                 continue;
             }
             $stockPriceInfo = StockPriceInfo::where('issue_id', $issue->id)->where('acquire_at', $yesterday)->first();
             preg_match('#<td class="txtright">(.*?)</td>#ms', $row, $matchesTemp);
             if ($kind == '75') {
                 $stockPriceInfo->average_75days = str_replace(',', '', $matchesTemp[1]);
             } elseif ($kind == '25') {
                 $stockPriceInfo->average_25days = str_replace(',', '', $matchesTemp[1]);
             }
             $stockPriceInfo->save();
             if ($kind == '75') {
                 preg_match('#<td class="txtright bold">(.*?)</td>#ms', $row, $matchesTemp);
                 $ranking75LowDiremption = new Ranking75LowDiremption();
                 $ranking75LowDiremption->acquire_at = $today;
                 $ranking75LowDiremption->order = $order;
                 $ranking75LowDiremption->issue_id = $issue->id;
                 $ranking75LowDiremption->price = str_replace(',', '', $matchesTemp[1]);
                 $ranking75LowDiremption->save();
             }
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $today = date('Y-m-d');
     $yesterday = date('Y-m-d', strtotime((date('N') == 1 ? '-3' : '-1') . ' day'));
     $issues = Issue::all();
     foreach ($issues as $issue) {
         $stockPriceInfoToday = new StockPriceInfo();
         $stockPriceInfoToday->acquire_at = $today;
         $stockPriceInfoYesterday = StockPriceInfo::where('issue_id', $issue->id)->where('acquire_at', $yesterday)->first();
         if (!$stockPriceInfoYesterday) {
             $stockPriceInfoYesterday = new StockPriceInfo();
             $stockPriceInfoYesterday->acquire_at = $yesterday;
         }
         $html = $this->getHtmlContent($this->getUrl($issue->code));
         $ret = preg_match_all('#<dl.*?</dl>#ms', $html, $matches);
         foreach ($matches[0] as $element) {
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">単元株数#ms', $element, $matchesTemp)) {
                 $issue->unit = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">前日終値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoYesterday->closing_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">始値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->opening_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">高値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->high_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">安値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->low_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">出来高#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->traded_volume = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">発行済株式数#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->number_of_stocks = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">配当利回り#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->dividend_yield = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<a[^>]+?>([^<]+)</a>.*1株配当#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->dividend_per_stock = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>.*?([^<()]+)</strong>.*<dt class="title">PER#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->per = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>.*?([^<()]+)</strong>.*<dt class="title">PBR#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->pbr = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<a[^>]+?>.*?([^<()]+)</a>.*EPS#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->eps = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<a[^>]+?>.*?([^<()]+)</a>.*BPS#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->bps = floatval(str_replace(',', '', $matchesTemp[1]));
             }
         }
         if ($issue->getOriginal() != $issue->getAttributes()) {
             $issue->save();
         }
         $issue->stockPricelInfos()->save($stockPriceInfoToday);
         $issue->stockPricelInfos()->save($stockPriceInfoYesterday);
     }
 }