Automation/app/Controllers/CrawlerController.php
2024-09-13 18:33:27 +09:00

32 lines
1.2 KiB
PHP

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