<?php
declare(strict_types=1);
namespace classes\Donors;
use Exception;
class EroTop extends Parser implements DonorInterface
{
public function images($url): array
{
$this->document->loadHtmlFile($url);
$items = $this->document->find('.highslide');
$images = [];
foreach ($items as $item) {
$href = $item->attr('href');
array_push($images, $href);
}
return $images;
}
public function list($url): array
{
$this->document->loadHtmlFile($url);
$items = $this->document->find('#short-stori a');
$list = [];
foreach ($items as $item) {
try {
$title = $item->first('.inftext')->first('b')->text();
$href = $item->attr('href');
preg_match('~/(?<listId>\d+)-~i', $href, $matches);
$list[] = [
'id' => $matches['listId'],
'title' => $title,
'url' => $href,
'images' => []
];
} catch (Exception $e) {
die($e);
}
}
return $list;
}
}