Files
symfonycast.local/app/Http/SymfonyCastDl/SymfonyCastDlService.php
2022-08-05 16:44:51 +02:00

41 lines
1.0 KiB
PHP

<?php
namespace App\Http\SymfonyCastDl;
use GuzzleHttp\TransferStats;
use DiDom\Document;
use GuzzleHttp\Client;
class SymfonyCastDlService
{
public function __construct(HtmlParser $htmlParser)
{
$client = new Client([
'base_uri' => "https://symfonycasts.com",
'cookies' => true
]);
$response = $client->get('login');
$token = $htmlParser->getCsrfToken($response);
$response = $client->post('login', [
'form_params' => [
// 'email' => 'krzysiej@gmail.com',
// 'password' => '',
'_csrf_token' => $token
],
'on_stats' => function (TransferStats $stats) use (&$currentUrl) {
$currentUrl = $stats->getEffectiveUri();
}
]);
$coursePage = $client->get('courses/filtering');
// dump($htmlParser->getCourses($coursePage));
$singleCoursePage = $client->get('screencast/api-platform');
dd($htmlParser->getCourseDetails($singleCoursePage));
}
}