louisperre / composer-td3
Scrap the TMDB website to get all sort of data
1.0.3
2023-07-06 13:25 UTC
Requires
- php: >= 8.0
- symfony/css-selector: ^5.4 || ^6.3
- symfony/dom-crawler: ^5.4 || ^6.3
- symfony/http-client: ^5.4 || ^6.3
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.6 || ^10.2
- symfony/var-dumper: ^5.4 || ^6.3
README
Information
Easily scrap the TMDB website
Features
- Scrap all the movies categories name
- Scrap all the movies categories slug
- Scrap all the movies related to a category
- Scrap all the data of a movie
Work without any api key
🔥 Installation 🔥
composer require louisperre/composer-td3
⚙️ Usage ⚙️
<?php use louisperr/ApiTmdb; $api = new ApiTmdb(); $categories = $api->getNameCategories() // array
✨ How does that work ? ✨
I use the HttpClient from Symfony to get the HTTP Code of TMDB :
$client = HttpClient::create(); $response = $client->request( 'GET', 'url' ); $content = $response->getContent();
After that I use the Crawler to find and loop over the content and get what I want :
$crawler = new Crawler($content); $list = $crawler ->filter('CSS SELECTOR') ->reduce(function (Crawler $node, $i) use (&$array) : bool { foreach ($node->filter('selector') as $something) { // Do something } })
The filter
function allow me to navigate inside the HTML CODE and the reduce
one act as a callback function to do some logic to the result and the result I want.
🔧 Local development 🔧
# Install the dependencies
composer install
# Test the type of all the project
php vendor/bin/phpstan analyze src --level=max
# Execute all the test
php vendor/bin/phpunit --testdox tests
📝 License 📝
Licensed under the terms of the MIT License.