64 lines
2.3 KiB
PHP
64 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\CLI;
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Libraries\MyCrawler\YamapLibrary;
|
|
use App\Libraries\Mangboard\BoardLibrary;
|
|
use App\Models\Mangboard\UserModel;
|
|
use App\Models\Mangboard\BoardModel;
|
|
use App\Entities\Mangboard\BoardEntity;
|
|
|
|
class Crawler extends BaseController
|
|
{
|
|
public function yamap(...$params): bool
|
|
{
|
|
try {
|
|
$isDebug = in_array("debug", $params);
|
|
//1. 사이트 로그인 처리
|
|
$userModel = new UserModel();
|
|
$user = $userModel->getEntityByID("idcjp");
|
|
// if (!in_array("skip_login", $params)) {
|
|
// $daemonidc = new MyWebLibrary(getenv('daemonidc.host.url'));
|
|
// $daemonidc->setDebug($isDebug);
|
|
// $daemonidc->login(
|
|
// getenv('daemonidc.login.url'),
|
|
// getenv('daemonidc.login.user_id'),
|
|
// getenv('daemonidc.login.user_password')
|
|
// );
|
|
// }
|
|
//2.Yamap사이트에서 자유게시판에서 최근 게시물 데이터 가져오기
|
|
$yamap = new YamapLibrary();
|
|
$yamap->setDebug($isDebug);
|
|
list($item, $fileInfos) = $yamap->execute();
|
|
|
|
//3.망보드 일반게시판에 게시물 등록 처리
|
|
if (!in_array("skip_create", $params)) {
|
|
$board = new BoardLibrary(new BoardModel(getenv("crawler.yamap.registration.table")));
|
|
$board->setDebug($isDebug);
|
|
|
|
//미디어관련정보 entity에 넣기
|
|
$entity = new BoardEntity();
|
|
$entity->title = $item["title"];
|
|
$entity->user_name = $item["nickname"];
|
|
$entity->reg_date = $item['time'];
|
|
$entity->hit = $item['hit'];
|
|
$entity->data_type = "html";
|
|
$entity->editor_type = "S";
|
|
foreach ($fileInfos as $fileInfo) {
|
|
$entity->content .= $fileInfo["mediatag"];
|
|
}
|
|
|
|
//망보드에 넣기
|
|
$board->create($entity);
|
|
}
|
|
|
|
log_message("notice", "Crawler->" . __FUNCTION__ . " 작업이 완료되었습니다.");
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
log_message("error", $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
}
|