extract(['data-src']);
if (count($attributes)) {
$url = $attributes[0];
}
}
break;
case 'img':
default:
$url = parent::getUrlByMediaType($node, $media_type, $attr);
break;
}
return $url;
}
//작성내용
//
//
protected function getDetailSelector(array $listInfo): array
{
$response = $this->getMySocket()->getContent($listInfo['detail_url']);
return array($this->getSelector($response, getenv("inven.view.content.tag")), $listInfo);
}
//리스트내용
//
//
//
// | 1589 |
//
//
// |
//
//
// 배수민
// |
// 09-15 |
// 1,502 |
// 1 |
//
//
//
public function execute(): void
{
$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("inven.view.test.url.{$this->getMyStorage()->getBoardName()}");
$listInfos[] = $listInfo;
} else {
$response = $this->getMySocket()->getContent(getenv("inven.list.url.{$this->getMyStorage()->getBoardName()}"));
$this->getSelector($response, getenv("inven.list.tag.{$this->getMyStorage()->getBoardName()}"))->each(
function (Crawler $node) use (&$listInfos): void {
$nickname = $node->filter(getenv("inven.list.item.nickname.tag"))->text();
$hit = $node->filter(getenv("inven.list.item.hit.tag"))->text();
$date = date("Y") . "-" . $node->filter(getenv("inven.list.item.date.tag"))->text();
//title및 detail url
$link_node = $node->filter(getenv("inven.list.item.link.tag"));
$detail_url = $link_node->attr("href");
$title = $link_node->text();
//title에서 예외사항비교
if (strpos($title, getenv("inven.list.tag.except.{$this->getMyStorage()->getBoardName()}")) === false) {
$listInfos[] = ['title' => $title, 'nickname' => $nickname, 'detail_url' => $detail_url, 'date' => $date, 'hit' => $hit];
}
}
);
}
if (!count($listInfos)) {
throw new \Exception("Target URL이 없습니다.");
}
$this->list_process(intval(getenv("inven.list.max_limit.{$this->getMyStorage()->getBoardName()}")), $listInfos);
log_message("notice", __FUNCTION__ . " 작업이 완료되었습니다.");
}
}