Automation init...3

This commit is contained in:
최준흠 2024-09-10 11:23:36 +09:00
parent 17f7065f7b
commit 32c58a2f76
2 changed files with 13 additions and 12 deletions

View File

@ -43,7 +43,9 @@ class YamapController extends CommonController
//3. DetailPage 처리 : bbs_view > div.contents 가진 객체를 찾아서 처리
$fileEntitys = $crawler->detailPage($item["detail_url"]);
//4.망보드 일반게시판에 게시물 등록 처리
$crawler->createBoard($item, $fileEntitys);
if (count($fileEntitys)) {
$crawler->createBoard($item, $fileEntitys);
}
$i++;
log_message("notice", "게시물 {$i}번째 {$item["nickname"]} 작업완료.");
} catch (\Exception $e) {

View File

@ -37,23 +37,22 @@ abstract class MyCrawlerLibrary extends CommonLibrary
//Download한 파일 저장후 추가작업시 사용
protected function download_process($entity, int $file_sequence)
{
return $entity;
}
final protected function download(string $mediaType, Crawler $crawler, array $options, array $entitys = []): array
{
$nodes = $this->getNodes($crawler, $options);
$file_sequence = 1;
foreach ($nodes as $node) {
list($fileName, $content) = $this->getMySocket()->download($node->attr($options["attr"]));
$entity = $this->getMyStorage()->save($fileName, $mediaType, $content, $file_sequence);
if ($entity === null) {
continue;
try {
list($fileName, $content) = $this->getMySocket()->download($node->attr($options["attr"]));
$entity = $this->getMyStorage()->save($fileName, $mediaType, $content, $file_sequence);
if ($entity === null) {
continue;
}
$entitys[] = $entity;
$file_sequence++;
} catch (\Exception $e) {
log_message("notice", $e->getMessage());
}
$entitys[] = $this->download_process($entity, $file_sequence);
$file_sequence++;
}
return $entitys;
}