Automationn init...
This commit is contained in:
parent
ca0a0a57ad
commit
8b3c16ccaf
@ -7,7 +7,7 @@ use App\Libraries\YamapLibrary;
|
||||
|
||||
class Crawler extends BaseController
|
||||
{
|
||||
public function yamap(...$params)
|
||||
public function yamap(...$params): bool
|
||||
{
|
||||
try {
|
||||
$isDebug = in_array("debug", $params);
|
||||
@ -15,7 +15,11 @@ class Crawler extends BaseController
|
||||
$library->setDebug($isDebug);
|
||||
//1. MainPage
|
||||
$url = getenv("yamap.url.main");
|
||||
$links = $library->getLinksByMainPage($url);
|
||||
$crawler = $library->getCrawlerByMainPage($url);
|
||||
$links = $library->getLinks($crawler,);
|
||||
if (!count($links)) {
|
||||
throw new \Exception("Target Links가 없습니다.");
|
||||
}
|
||||
//2. TargetPage : div.contents 가진 객체를 찾아서 첫번쨰 요소에서만 참조
|
||||
$url = !in_array("debug", $params) ? getenv("yamap.url.test") : $links[0]["href"];
|
||||
$crawler = $library->getCrawlerByDetailPage($url);
|
||||
|
||||
@ -20,7 +20,7 @@ class YamapLibrary
|
||||
$this->_host = $host;
|
||||
}
|
||||
|
||||
public function getMyWeb()
|
||||
public function getMyWeb(): MyWebLibrary
|
||||
{
|
||||
if ($this->_web === null) {
|
||||
$this->_web = new MyWebLibrary($this->getHost());
|
||||
@ -28,7 +28,7 @@ class YamapLibrary
|
||||
}
|
||||
return $this->_web;
|
||||
}
|
||||
public function getMyStorage()
|
||||
public function getMyStorage(): MyStorageLibrary
|
||||
{
|
||||
if ($this->_storage === null) {
|
||||
$this->_storage = new MyStorageLibrary();
|
||||
@ -36,7 +36,7 @@ class YamapLibrary
|
||||
}
|
||||
return $this->_storage;
|
||||
}
|
||||
public function getMyCrawler()
|
||||
public function getMyCrawler(): MyCrawlerLibrary
|
||||
{
|
||||
if ($this->_crawler === null) {
|
||||
$this->_crawler = new MyCrawlerLibrary();
|
||||
@ -96,7 +96,7 @@ class YamapLibrary
|
||||
}
|
||||
|
||||
// 파일 다운로드 메서드
|
||||
final public function download($url)
|
||||
final public function download($url): bool
|
||||
{
|
||||
try {
|
||||
$fileNames = explode('/', $url);
|
||||
@ -130,15 +130,10 @@ class YamapLibrary
|
||||
}
|
||||
}
|
||||
|
||||
public function getLinksByMainPage(string $url): array
|
||||
public function getCrawlerByMainPage(string $url): Crawler
|
||||
{
|
||||
$html = $this->getMyWeb()->getContent($url);;
|
||||
$crawler = $this->getMyCrawler()->createCrawler($html)->filter("div.bbs_list")->first();;
|
||||
$links = $this->getLinks($crawler,);
|
||||
if (!count($links)) {
|
||||
throw new \Exception("Target Links가 없습니다.");
|
||||
}
|
||||
return $links;
|
||||
return $this->getMyCrawler()->createCrawler($html)->filter("div.bbs_list")->first();
|
||||
}
|
||||
public function getCrawlerByDetailPage(string $url): Crawler
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user