Download the PHP package rem42/scraper without Composer
On this page you can find all versions of the php package rem42/scraper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download rem42/scraper
More information about rem42/scraper
Files in rem42/scraper
Download rem42/scraper
More information about rem42/scraper
Files in rem42/scraper
Please rate this library. Is it a good library?
Informations about the package scraper
Scraper
Lightweight toolbox to build reusable "scrapers":
- Declare a Request class annotated with the PHP attribute
#[Scraper(...)]. - Provide the corresponding Api class (replace "Request" with "Api" in the name) which extends
\Scraper\Scraper\Api\AbstractApiand implementsexecute(). - Use
\Scraper\Scraper\Clientwith anHttpClientInterfaceto execute the request and retrieve the deserialized object.
Badges
Installation
Short introduction
The package centralizes the following logic:
- A Request (under
src/Request/) defines the necessary data and exposes getters used in path variables. - The attribute
#[\Scraper\Scraper\Attribute\Scraper(...)](on the Request) describesmethod,scheme,host,path. \Scraper\Scraper\Client::send()reads this attribute (viaExtractAttribute), builds the HTTP options (headers, query, body, json, auth) according to the interfaces implemented by the Request, then performs the HTTP call.- The matching Api class (eg:
FooApi) is instantiated and itsexecute()method returns the final object/array/string.
Quickstart (minimal example)
Schematic example (adapt according to your autoload/imports). Examples use use imports:
Important conventions
- PSR-4 root namespace:
Scraper\\Scraper\\->src/(seecomposer.json). - Naming convention:
XRequest->XApi(Client performs this replacement automatically using reflection). - In the
pathattribute, variables{name}are replaced by callinggetName()on the Request instance (seesrc/Attribute/ExtractAttribute.php). - Implement the interfaces in
src/Request/to enable options:RequestHeaders,RequestQuery,RequestBody,RequestBodyJson,RequestAuthBearer,RequestAuthBasic.
Tests / quality / style
-
Run unit tests:
-
Static analysis (phpstan):
- Check / apply coding style (php-cs-fixer):
PHP compatibility
composer.json requires php: ^8.4 — the code uses enums and recent types, so PHP 8.4+ is recommended.
Resources and documentation for agents
- Agent helper file:
AGENTS.md(tips, patterns, commands). Seepackages/scraper/AGENTS.md. - Key code points:
src/Client.php,src/Attribute/ExtractAttribute.php,src/Factory/SerializerFactory.php.
Non-exhaustive list of published scrapers
- rem42/scraper-allocine
- rem42/scraper-colissimo
- rem42/scraper-deezer
- rem42/scraper-giantbomb
- rem42/scraper-jeuxvideo
- rem42/scraper-prestashop
- rem42/scraper-shopify
- rem42/scraper-tmdb
- rem42/scraper-tnt
Contributing
See AGENTS.md for rules and patterns to follow. For PRs: green tests + highest phpstan level.
All versions of scraper with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
symfony/http-client-contracts Version ^3.5
symfony/serializer-pack Version ^1.3
symfony/http-client-contracts Version ^3.5
symfony/serializer-pack Version ^1.3
The package rem42/scraper contains the following files
Loading the files please wait ...