Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

By Running "php artisan roach:run MySpider" unable to scrap any data. #20

Closed
farsidd opened this issue Apr 25, 2023 · 3 comments
Closed

Comments

@farsidd
Copy link

farsidd commented Apr 25, 2023

I am working in Laravel 9.0. Whenever i am running command I'm not getting anything in Log file. See the attached pic of log file. Request sent successfully but no data scrapped.

Here is the view of log file
logFile

here is the view of my spider file
spider

i have installed this version of roach-php: "roach-php/laravel": "^2.0"

Is there anything I'm missing?

@DodgeWhale
Copy link

@farsidd Hey! I ran into the same issue you were having. This is what I did to fix it.

From the root of the project, I ran
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
Which generates a key.pem and cert.pem file.

Then, I override the base method initialRequests found in RoachPHP\Spider\AbstractSpider.

/**
 * @return Request[]
 */
protected function initialRequests(): array
{
    return \array_map(
        fn (string $url): Request => new Request(
            $this->requestMethod,
            $url,
            [$this, 'parse'],
            [
                'cert' => base_path('cert.pem'),
                'ssl_key' => base_path('key.pem')
             ]
        ),
        $this->configuration->startUrls
    );
}

base_path reference https://laravel.com/docs/10.x/helpers#method-base-path
openssl req reference https://support.microfocus.com/kb/doc.php?id=7013103

However, if the page you're trying to request relies on JavaScript to load the DOM elements you're selecting, I'm not sure a fix for that yet (using RoachPHP at least).

Hope this helps you, or anyone else having this issue.

@farsidd
Copy link
Author

farsidd commented May 1, 2023

Sure. I will check that thing.

@ksassnowski
Copy link
Contributor

I’m moving this to discussions as this seems more related to scraping a particular page than a bug with the package.

@roach-php roach-php locked and limited conversation to collaborators Mar 23, 2024
@ksassnowski ksassnowski converted this issue into discussion #27 Mar 23, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants