Automation init...1
This commit is contained in:
parent
7c1148abd7
commit
a83c1629cc
@ -30,7 +30,7 @@ class Crawler extends BaseController
|
||||
$yamap->setMyWeb($myWeb);
|
||||
$yamap->setMyStorage($storage);
|
||||
$yamap->setMyCrawler($crawler);
|
||||
list($nickname, $mediaInfos, $mediaTags) = $yamap->build();
|
||||
list($title, $nickname, $mediaInfos, $mediaTags) = $yamap->build();
|
||||
}
|
||||
// //2. 사이트 로그인 처리
|
||||
// if (!in_array("skip_login", $params)) {
|
||||
@ -49,7 +49,8 @@ class Crawler extends BaseController
|
||||
|
||||
//미디어관련정보 entity에 넣기
|
||||
$entity = new BoardEntity();
|
||||
$entity->title = $nickname;
|
||||
$entity->title = $title;
|
||||
$entity->user_name = $nickname;
|
||||
$entity->data_type = "html";
|
||||
$entity->editor_type = "S";
|
||||
$entity->content = is_array($mediaTags) ? implode("\n", $mediaTags) : $mediaTags;
|
||||
|
||||
@ -113,7 +113,7 @@ class YamapLibrary extends CommonLibrary
|
||||
$url = getenv("yamap.list.url");
|
||||
$crawler = $this->getCrawler($url, getenv("yamap.list.tag"));
|
||||
$item_tag = getenv("yamap.list.item.tag");
|
||||
$item_subject_tag = getenv("yamap.list.item.subject.tag");
|
||||
$item_link_tag = getenv("yamap.list.item.link.tag");
|
||||
$item_nickname_tag = getenv("yamap.list.item.nickname.tag");
|
||||
$item_nickname_except = getenv("yamap.list.item.nickname.except");
|
||||
|
||||
@ -121,7 +121,7 @@ class YamapLibrary extends CommonLibrary
|
||||
//div.bbs_item를 가진 객체를 찾아서 같은 형식의 객체(sibling)를 배열로 넘김
|
||||
$crawler->filter($item_tag)->each(
|
||||
function (Crawler $node) use (
|
||||
$item_subject_tag,
|
||||
&$item_link_tag,
|
||||
&$item_nickname_tag,
|
||||
&$item_nickname_except,
|
||||
&$lists
|
||||
@ -131,18 +131,20 @@ class YamapLibrary extends CommonLibrary
|
||||
log_message("debug", $item_nickname_tag . ":" . $nickname);
|
||||
if ($nickname != $item_nickname_except) {
|
||||
//작성자가 "관리자"가 아니 게시물이면 해당 bbs_item에서 a.list_subject 객체를 찾아서
|
||||
$url = $node->filter($item_subject_tag)->attr("href");
|
||||
$lists[] = ['nickname' => $nickname, 'url' => $url];
|
||||
$link_node = $node->filter($item_link_tag);
|
||||
$url = $link_node->attr("href");
|
||||
$title = $link_node->children()->last()->text();
|
||||
$lists[] = ['title' => $title, 'nickname' => $nickname, 'url' => $url];
|
||||
}
|
||||
}
|
||||
);
|
||||
if (!count($lists)) {
|
||||
throw new \Exception("Target URL이 없습니다.");
|
||||
}
|
||||
return array($lists[0]["nickname"], $lists[0]["url"]);
|
||||
return array($lists[0]["title"], $lists[0]["nickname"], $lists[0]["url"]);
|
||||
}
|
||||
|
||||
public function detailPage($url): array
|
||||
public function detailPage(string $url): array
|
||||
{
|
||||
$crawler = $this->getCrawler($url, getenv("yamap.view.content.tag"));
|
||||
$mediaTags = [];
|
||||
@ -179,13 +181,14 @@ class YamapLibrary extends CommonLibrary
|
||||
{
|
||||
//1. 해당사이트 MainPage 처리
|
||||
if ($this->getDebug()) {
|
||||
$title = getenv("yamap.view.test.title");
|
||||
$nickname = getenv("yamap.view.test.nickname");
|
||||
$detail_url = getenv("yamap.view.test.url");
|
||||
} else {
|
||||
list($nickname, $detail_url) = $this->mainPage();
|
||||
list($title, $nickname, $detail_url) = $this->mainPage();
|
||||
}
|
||||
//2. DetailPage 처리 : bbs_view > div.contents 가진 객체를 찾아서 처리
|
||||
list($mediaInfos, $mediaTags) = $this->detailPage($detail_url);
|
||||
return array($nickname, $mediaInfos, $mediaTags);
|
||||
return array($title, $nickname, $mediaInfos, $mediaTags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ abstract class BoardModel extends CommonModel
|
||||
|
||||
protected function __construct(array $fields = [])
|
||||
{
|
||||
$fields = ["title", "data_type", "editor_type", "content", ...$fields];
|
||||
$fields = ["title", "user_name", "data_type", "editor_type", "content", ...$fields];
|
||||
parent::__construct($fields);
|
||||
}
|
||||
public function getTitleField(): string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user