Automation/app/Controllers/CrawlerController.php
2024-09-12 19:07:29 +09:00

38 lines
1.3 KiB
PHP

<?php
namespace App\Controllers;
use App\Libraries\MyCrawler\YamapLibrary as MyCrawler;
use App\Controllers\CommonController;
use App\Models\Mangboard\UserModel;
class CrawlerController extends CommonController
{
public function yamap(...$params): string
{
try {
//1. 사이트 로그인 처리
$userModel = new UserModel();
$userEntity = $userModel->getEntityByID("idcjp");
// $daemonidc = new MySocketLibrary(getenv('daemonidc.host.url'));
// $daemonidc->setDebug($isDebug);
// $daemonidc->login(
// getenv('daemonidc.login.url'),
// getenv('daemonidc.login.user_id'),
// getenv('daemonidc.login.user_password')
// );
//2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달.
$crawler = new MyCrawler();
$crawler->setUserEntity($userEntity);
if (in_array("debug", $params)) {
$crawler->setDebug(true);
}
$crawler->execute();
return "완료되었습니다.";
} catch (\Exception $e) {
log_message("error", $e->getMessage());
return $e->getMessage();
}
}
}