Automation/app/Controllers/CLI/Crawler.php
2024-09-02 00:04:12 +09:00

32 lines
1.0 KiB
PHP

<?php
namespace App\Controllers\CLI;
use App\Libraries\CrawlerLibrary;
use App\Controllers\BaseController;
class Crawler extends BaseController
{
public function yamap()
{
try {
$library = new CrawlerLibrary("https://www.yamap16.com");
echo "Host-> " . $library->getHost() . "\n";
// $html = $library->getInnerHTML("/Board/List.aspx?id=free&ca=1");
// $links = $library->getLinks($html, "a.list_subject");
$url = "/Board/View.aspx?id=free&ca=1&rno=192681&page=1";
$html = $library->getInnerHTML($url, "div.contents p");
$images = $library->getImages($html);
foreach ($images as $image) {
echo "Image-> " . $image . "\n";
$library->download($image);
}
log_message("info", "완료되었습니다.");
return true;
} catch (\Exception $e) {
log_message("error", $e->getMessage());
return false;
}
}
}