Automation init...3

This commit is contained in:
최준흠 2024-09-16 20:17:39 +09:00
parent 6305932285
commit 7cd6f131c1

View File

@ -101,25 +101,28 @@ abstract class MyCrawler extends CommonLibrary
$storages = []; //CreateBoard에서 사용을 위해 DetailPage마다 초기화
// log_message("debug", var_export($urls, true));
foreach ($media_urls as $media_type => $urls) {
$total = count($urls);
foreach ($urls as $url) {
log_message("notice", __FUNCTION__ . " {$file_sequence}번째/총:{$total} MediaType->{$media_type} 작업 시작");
try {
list($file_name, $content) = $this->media_download($media_type, $url);
$storages[] = $this->media_save($file_sequence, $media_type, $file_name, $content);
$file_sequence++;
log_message("notice", __FUNCTION__ . " MediaType->{$media_type} 작업 완료");
} catch (\Exception $e) {
log_message("warning", sprintf(
"\n---%s MediaType->%s 오류---\n%s\n-----------------------------------------\n",
"\n---%s MediaType->%s {$file_sequence}번째/총:{$total} 오류---\n%s\n-----------------------------------------\n",
__FUNCTION__,
$media_type,
$e->getMessage()
));
}
log_message("notice", __FUNCTION__ . " {$file_sequence}번째/총:{$total} MediaType->{$media_type} 작업 완료");
$file_sequence++;
}
}
$i = 1;
$total = count($storages);
foreach ($storages as $storage) {
log_message("debug", __FUNCTION__ . " 결과{$i}:" . $storage->getOriginName());
log_message("debug", __FUNCTION__ . " {$i}번째/총:{$total} 결과=>" . $storage->getOriginName());
$i++;
}
return $storages;
@ -136,19 +139,19 @@ abstract class MyCrawler extends CommonLibrary
$i = 1;
foreach ($listInfos as $listInfo) {
if ($i <= $max_limit) {
log_message("notice", "게시물 {$i}번째/총:{$total} {$listInfo["nickname"]} 작업시작");
try {
log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업시작");
//listInfo는 title,작성자,작성시간등등의 정보를 가지고 있어 detail_page 처리 안에서 바뀔 수 있으므로 다시 반환 받는다.
$this->detail_page($i, $listInfo);
log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업완료.");
$i++;
} catch (\Exception $e) {
log_message("warning", sprintf(
"\n---%s 오류---\n%s\n-----------------------------------------\n",
"\n---%s {$i}번째/총:{$total} 오류---\n%s\n-----------------------------------------\n",
__FUNCTION__,
$e->getMessage()
));
}
log_message("notice", "게시물 {$i}번째/총:{$total} {$listInfo["nickname"]} 작업완료.");
$i++;
}
}
}