Skip to content

Scraping food recipe #59

Answered by rabol
rabol asked this question in Q&A
Sep 19, 2022 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Here is the result:


/**
     * @param Response $response
     * @return Generator
     */
    public function parse(Response $response): Generator
    {
        yield $this->item([
            'title' => $response->filter('h2.wprm-recipe-name')->text(''),
            'summary' => $response->filter('div.wprm-recipe-summary')->text(''),
            'course' => $response->filter('span.wprm-recipe-course')->text(''),
            'ingredients' => $response->filter('ul.wprm-recipe-ingredients li')->each(fn ( Crawler $entry) => $entry->text()),
            'instructions' => $response->filter('ol.wprm-recipe-instructions li')->each(fn(Crawler $entry) => $entry->text()),
            'prepTime' =>…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@rabol
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rabol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants