setDebug(true); } //1. 사이트 로그인 처리 $user = $crawler->login(); $crawler->getMyStorage()->setUser($user); $itemInfos = []; //2. 해당사이트 MainPage 처리 if ($crawler->getDebug()) { $itemInfos[] = [ 'title' => getenv("yamap.view.test.title"), 'nickname' => getenv("yamap.view.test.nickname"), 'detail_url' => getenv("yamap.view.test.url"), 'time' => date("Y-m-d H:i:s"), 'hit' => 1 ]; } else { $itemInfos = $crawler->mainPage(getenv("yamap.list.url")); } if (!count($itemInfos)) { throw new \Exception("Yamap 사이트에서 게시물이 존재하지 않습니다."); } //Limit가 0이면 $itemInfos 갯수만큼 다하고, LIMIT 갯수 혹은 $items의 갯수중 작은수만큼 한다. $max_limit = intval(getenv("yamap.list.max_limit")); if ($max_limit) { $max_limit = count($itemInfos) <= $max_limit ? count($itemInfos) : $max_limit; } else { $max_limit = count($itemInfos); } $i = 1; foreach ($itemInfos as $itemInfo) { if ($i < $max_limit) { try { log_message("notice", "게시물 {$i}번째 {$itemInfo["nickname"]} 작업시작"); $crawler->detailPage($itemInfo); log_message("notice", "게시물 {$i}번째 {$itemInfo["nickname"]} 작업완료."); $i++; } catch (\Exception $e) { log_message("debug", $e->getMessage()); } } } log_message("notice", "Crawler->" . __FUNCTION__ . " 작업이 완료되었습니다."); return "완료되었습니다."; } catch (\Exception $e) { log_message("error", $e->getMessage()); return $e->getMessage(); } } }