File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ final class Manager
3030 \Kami \Cocktail \Scraper \Sites \MakeMeACocktail::class,
3131 \Kami \Cocktail \Scraper \Sites \KindredCocktails::class,
3232 \Kami \Cocktail \Scraper \Sites \CraftedPour::class,
33+ \Kami \Cocktail \Scraper \Sites \CocktailExplorer::class,
3334 ];
3435
3536 public function __construct (private readonly string $ url )
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Kami \Cocktail \Scraper \Sites ;
6+
7+ use Kami \RecipeUtils \AmountValue ;
8+ use Kami \RecipeUtils \RecipeIngredient ;
9+ use Symfony \Component \DomCrawler \Crawler ;
10+
11+ class CocktailExplorer extends DefaultScraper
12+ {
13+ public static function getSupportedUrls (): array
14+ {
15+ return [
16+ 'https://www.cocktailexplorer.co ' ,
17+ ];
18+ }
19+
20+ public function ingredients (): array
21+ {
22+ $ result = $ this ->crawler ->filter ('.video__recipe__ingredients li ' )->each (function (Crawler $ node ): RecipeIngredient {
23+ $ amount = $ node ->filter ('.video__recipe__ingredient__quantity ' )->attr ('data-ingredient-amount ' );
24+ $ unit = $ node ->filter ('.video__recipe__ingredient__quantity ' )->attr ('data-ingredient-unit ' );
25+ $ ingredient = $ node ->filter ('strong ' )->text ();
26+
27+ return new RecipeIngredient (
28+ name: $ ingredient ,
29+ amount: AmountValue::fromString ($ amount ),
30+ units: $ unit ,
31+ source: $ node ->text (),
32+ );
33+ });
34+
35+ return $ result ;
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments