Automation init...3
This commit is contained in:
parent
17f7065f7b
commit
32c58a2f76
@ -43,7 +43,9 @@ class YamapController extends CommonController
|
|||||||
//3. DetailPage 처리 : bbs_view > div.contents 가진 객체를 찾아서 처리
|
//3. DetailPage 처리 : bbs_view > div.contents 가진 객체를 찾아서 처리
|
||||||
$fileEntitys = $crawler->detailPage($item["detail_url"]);
|
$fileEntitys = $crawler->detailPage($item["detail_url"]);
|
||||||
//4.망보드 일반게시판에 게시물 등록 처리
|
//4.망보드 일반게시판에 게시물 등록 처리
|
||||||
$crawler->createBoard($item, $fileEntitys);
|
if (count($fileEntitys)) {
|
||||||
|
$crawler->createBoard($item, $fileEntitys);
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
log_message("notice", "게시물 {$i}번째 {$item["nickname"]} 작업완료.");
|
log_message("notice", "게시물 {$i}번째 {$item["nickname"]} 작업완료.");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
@ -37,23 +37,22 @@ abstract class MyCrawlerLibrary extends CommonLibrary
|
|||||||
|
|
||||||
|
|
||||||
//Download한 파일 저장후 추가작업시 사용
|
//Download한 파일 저장후 추가작업시 사용
|
||||||
protected function download_process($entity, int $file_sequence)
|
|
||||||
{
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
final protected function download(string $mediaType, Crawler $crawler, array $options, array $entitys = []): array
|
final protected function download(string $mediaType, Crawler $crawler, array $options, array $entitys = []): array
|
||||||
{
|
{
|
||||||
$nodes = $this->getNodes($crawler, $options);
|
$nodes = $this->getNodes($crawler, $options);
|
||||||
$file_sequence = 1;
|
$file_sequence = 1;
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
list($fileName, $content) = $this->getMySocket()->download($node->attr($options["attr"]));
|
try {
|
||||||
$entity = $this->getMyStorage()->save($fileName, $mediaType, $content, $file_sequence);
|
list($fileName, $content) = $this->getMySocket()->download($node->attr($options["attr"]));
|
||||||
if ($entity === null) {
|
$entity = $this->getMyStorage()->save($fileName, $mediaType, $content, $file_sequence);
|
||||||
continue;
|
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;
|
return $entitys;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user