Started working on parsing symfony cast pages.

This commit is contained in:
Krzysztof Płaczek
2022-08-05 16:44:51 +02:00
parent 3a6a2252a3
commit 119b94470f
6 changed files with 152 additions and 4 deletions

View File

@@ -0,0 +1,40 @@
<?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));
}
}