Started working on parsing symfony cast pages.
This commit is contained in:
40
app/Http/SymfonyCastDl/SymfonyCastDlService.php
Normal file
40
app/Http/SymfonyCastDl/SymfonyCastDlService.php
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user