PHPackages                             kurozumi/web-scraper-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kurozumi/web-scraper-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

kurozumi/web-scraper-bundle
===========================

v6.1.5(3y ago)021MITPHPPHP &gt;=8.1

Since Oct 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kurozumi/web-scraper-bundle)[ Packagist](https://packagist.org/packages/kurozumi/web-scraper-bundle)[ RSS](/packages/kurozumi-web-scraper-bundle/feed)WikiDiscussions 6.1 Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (7)Used By (0)

WebScraperBundle
================

[](#webscraperbundle)

Manage multiple Web Scraper bundle for Symfony.

Install
-------

[](#install)

```
composer req kurozumi/web-scraper-bundle

```

How to use
----------

[](#how-to-use)

```
namespace App\Command;

use Kurozumi\WebScraperBundle\Service\Context;
use Kurozumi\WebScraperBundle\Service\Scraper\RssScraper;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;

#[AsCommand(
    name: 'app:scraper'
)]
class ScraperCommand extends Command
{
    private Context $context;

    public function __construct(Context $context)
    {
        $this->context = $context;

        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $feeds = [
            'https://aaa.rss.xml',
            'https://bbb.rss.xml'
        ];

        $items = [];
        foreach ($feeds as $feed) {
            $data = $this->content->getData($feed);
            if (null !== $data) {
                foreach ($data['items'] as $item) {
                    switch ($data['name']) {
                        case RssScraper::class:
                            $items[] = [
                                'title' => $item->filter('title')->text(),
                                'url' => $item->filter('link')->text()
                            ];
                            break;
                    }
                }
            }
        }

        print_r($items);

        return Command::SUCCESS;
    }
}

```

Custom Scraper
--------------

[](#custom-scraper)

### Feed

[](#feed)

```
