Merge pull request #430 from shikorism/fix/429-fanza-cookie

FANZA: 年齢認証Cookieを送信する
This commit is contained in:
shibafu 2020-07-09 00:33:09 +09:00 committed by GitHub
commit d83516f394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
namespace App\MetadataResolver; namespace App\MetadataResolver;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
class FanzaResolver implements Resolver class FanzaResolver implements Resolver
@ -43,7 +44,9 @@ class FanzaResolver implements Resolver
public function resolve(string $url): Metadata public function resolve(string $url): Metadata
{ {
$res = $this->client->get($url); $cookieJar = CookieJar::fromArray(['age_check_done' => '1'], 'dmm.co.jp');
$res = $this->client->get($url, ['cookies' => $cookieJar]);
$html = (string) $res->getBody(); $html = (string) $res->getBody();
$crawler = new Crawler($html); $crawler = new Crawler($html);