32 lines
1.0 KiB
PHP
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;
|
|
}
|
|
}
|
|
}
|