//
//
//
//
protected function getDetailSelector(array $listInfo): array
{
$response = $this->getMySocket()->getContent($listInfo['detail_url']);
//작성시간
$selector = $this->getSelector($response, getenv("sir.view.date.tag"));
//Date Format이 맞지않아 변경해주기위함 : 2024.09.13 00:24:04 -> 2024-09-13 00:24:04
$listInfo['date'] = trim($selector->text());
$listInfo['date'] = DateTime::createFromFormat('Y.m.d H:i:s', $listInfo['date']);
$listInfo['date'] = $listInfo['date']->format('Y-m-d H:i:s');
return array($this->getSelector($response, tag: getenv("sir.view.content.tag")), $listInfo);
}
//리스트 내용
//
//
// 졸고 있는 여군
// 6
// yeeyuu | 6 | 369 | No 89372 | 2024-09-13
// |
public function execute(string $board_name, string $user_id = null, ...$params): void
{
try {
//추가옵션
$this->isDebug = in_array('debug', $params);
$this->isCopy = in_array('copy', $params);
$this->setBoardName($board_name);
$this->login_process($user_id);
//실행
$listInfos = [];
if ($this->isDebug) {
$listInfo = [];
$listInfo['title'] = 'test_title';
$listInfo['nickname'] = 'test_name';
$listInfo['hit'] = 1;
$listInfo['date'] = date("Y-m-d H:i:s");
$listInfo['detail_url'] = getenv("sir.view.test.url.{$this->getBoardName()}");
$listInfos[] = $listInfo;
} else {
$response = $this->getMySocket()->getContent(getenv("sir.list.url.{$this->getBoardName()}"));
$this->getSelector($response, getenv("sir.list.tag.{$this->getBoardName()}"))->each(
function (Crawler $node) use (&$listInfos): void {
$link_node = $node->filter(getenv("sir.list.item.link.tag"));
// href url의 맨 앞이 /가 두개라서 한개를 빼기위함
$detail_url = $this->changeURLByCrawler($link_node->attr("href"));
// $detail_url = $link_node->attr("href");
$title = $link_node->text();
$nickname = $node->filter(getenv("sir.list.item.nickname.tag"))->text();
$hit = $node->filter(getenv("sir.list.item.hit.tag"))->text();
// $date = $node->filter(getenv("sir.list.item.date.tag"))->text();
$listInfos[] = ['title' => $title, 'nickname' => $nickname, 'detail_url' => $detail_url, 'date' => "", 'hit' => $hit];
}
);
}
if (!count($listInfos)) {
throw new \Exception("Target URL이 없습니다.");
}
$this->list_process(intval(getenv("sir.list.max_limit.{$this->getBoardName()}")), $listInfos);
log_message("notice", __FUNCTION__ . " 작업이 완료되었습니다.");
} catch (\Exception $e) {
log_message("warning", sprintf(
"\n---%s 오류---\n%s\n-----------------------------------------\n",
__FUNCTION__,
$e->getMessage()
));
}
}
}