最初にやったニジエに抜けがあった
This commit is contained in:
parent
24dee801ad
commit
51f097fdf0
@ -6,12 +6,19 @@ use GuzzleHttp\Client;
|
|||||||
|
|
||||||
class NijieResolver implements Resolver
|
class NijieResolver implements Resolver
|
||||||
{
|
{
|
||||||
/** @var Client */
|
/**
|
||||||
|
* @var Client
|
||||||
|
*/
|
||||||
protected $client;
|
protected $client;
|
||||||
|
/**
|
||||||
|
* @var OGPResolver
|
||||||
|
*/
|
||||||
|
private $ogpResolver;
|
||||||
|
|
||||||
public function __construct(Client $client)
|
public function __construct(Client $client, OGPResolver $ogpResolver)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
$this->ogpResolver = $ogpResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolve(string $url): Metadata
|
public function resolve(string $url): Metadata
|
||||||
@ -26,8 +33,7 @@ class NijieResolver implements Resolver
|
|||||||
$client = $this->client;
|
$client = $this->client;
|
||||||
$res = $client->get($url);
|
$res = $client->get($url);
|
||||||
if ($res->getStatusCode() === 200) {
|
if ($res->getStatusCode() === 200) {
|
||||||
$ogpResolver = new OGPResolver();
|
$metadata = $this->ogpResolver->parse($res->getBody());
|
||||||
$metadata = $ogpResolver->parse($res->getBody());
|
|
||||||
|
|
||||||
$dom = new \DOMDocument();
|
$dom = new \DOMDocument();
|
||||||
@$dom->loadHTML(mb_convert_encoding($res->getBody(), 'HTML-ENTITIES', 'UTF-8'));
|
@$dom->loadHTML(mb_convert_encoding($res->getBody(), 'HTML-ENTITIES', 'UTF-8'));
|
||||||
|
Loading…
Reference in New Issue
Block a user