Skip to content
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

Chrome client crontab #622

Open
XhonorSkillline opened this issue Jan 19, 2024 · 0 comments
Open

Chrome client crontab #622

XhonorSkillline opened this issue Jan 19, 2024 · 0 comments

Comments

@XhonorSkillline
Copy link

XhonorSkillline commented Jan 19, 2024

When using the functionality via cron, the file completes its work before receiving the result from ChromeClient (even with the wait functionality). What to do in this case? How can I make cron wait for the results from the browser to complete?

function example($url) {
        $client = Client::createChromeClient(null, null, [
            'port' => $availablePort,
        ]);
        
        $client->request('GET', $url);
        $client->waitForElementToContain('body', '{"status":"success"', 10);
        $data = $client->getCrawler()->filter('body')->text();
        
        $client->quit();

        return $data;
}

Cron function:

foreach($lala as $url) {
        $data[] = example($url);
}

print_r($data); // empty result instantly without waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant