Somehow... a complete (functional) suite of tests for Endpoints
This commit is contained in:
1 parent
a429befc94
commit
9cdd917297
2 files changed
+155
-8
No files matched your search
+9
-8
@@ -109,19 +109,20 @@ class Endpoint
|
||||
|
||||
private function parseAuthor(Crawler $document): Author
|
||||
{
|
||||
if (!$document->count()) {
|
||||
return new Author();
|
||||
}
|
||||
|
||||
$card = $document->filter('.h-card');
|
||||
|
||||
if (!$card->count()) {
|
||||
$card = $document->closest('.h-card');
|
||||
return $this->parseAuthor($document->ancestors());
|
||||
}
|
||||
|
||||
if ($card && $card->count()) {
|
||||
$name = $card->filter('.p-name')?->text("");
|
||||
$url = $card->filter('.u-url')->count() ? $card->filter('.u-url')->attr('href') : "";
|
||||
$photo = $card->filter('.u-photo')->count() ? $card->filter('.u-photo')->attr('src') : "";
|
||||
$name = $card->filter('.p-name')?->text($card->text(""));
|
||||
$url = $card->filter('.u-url')->count() ? $card->filter('.u-url')->attr('href') : ($card->attr('href') ?? "");
|
||||
$photo = $card->filter('.u-photo')->count() ? $card->filter('.u-photo')->attr('src') : "";
|
||||
|
||||
return new Author(null, $name, $url, $photo);
|
||||
}
|
||||
return new Author();
|
||||
return new Author(null, $name, $url, $photo);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user