roach-php / core

The complete web scraping toolkit for PHP.

Home Page:https://roach-php.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overriding Spider conf or passing context doesn't work

wassim opened this issue · comments

I'm calling another spider from my main spider with overrides and context but the second spider doesn't catch any of those.

class MainSpider extends BasicSpider
{
    ...

    public function parse(Response $response): Generator
    {
        ...

        Roach::startSpider(
            AnotherSpider::class,
            new Overrides(startUrls: ['https://github.com']),
            context: ['name' => 'test']
    )
class AnotherSpider extends BasicSpider
{
    // here I have to redefine $startUrls because the spider doesn't apply the overrides...

    public function parse(Response $response): Generator
    {
        dd($this-context); // returns empty array
    }
}

Can you provide an example repository that reproduces this issue?

Closing this due to inactivity. Feel free to reopen if you have more information.