Skip to content

Commit

Permalink
fix #325 [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Irfan committed Sep 16, 2020
1 parent d6b281f commit 86146bd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Parser/Top/TopListItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Parser\Top;

use Jikan\Exception\ParserException;
use Jikan\Helper\JString;
use Jikan\Helper\Parser;
use Jikan\Model\Common\MalUrl;
Expand Down Expand Up @@ -38,10 +39,25 @@ public function __construct(Crawler $crawler)
/**
* @return \Jikan\Model\Common\MalUrl
* @throws \InvalidArgumentException
* @throws ParserException
*/
public function getMalUrl(): MalUrl
{
return (new MalUrlParser($this->crawler->filterXPath('//a[contains(@class,"fs14 fw-b")][1]')))->getModel();
// For Anime/Manga
$node = $this->crawler->filterXPath('//td[contains(@class, "title")]/a');

if ($node->count()) {
return (new MalUrlParser($node))->getModel();
}

// For Characters/People
$node = $this->crawler->filterXPath('//td[contains(@class, "people")]/a');

if ($node->count()) {
return (new MalUrlParser($node))->getModel();
}

throw new ParserException('Failed to parse MalUrl');
}

/**
Expand Down

0 comments on commit 86146bd

Please sign in to comment.