A
A
Alexey Reut2021-04-14 17:43:50
Laravel
Alexey Reut, 2021-04-14 17:43:50

How to make friends Laravel Dusc and proxy?

Good day! Faced with the task of parsing a site, or rather a large number of sites. All sites are +\- of the same type. Decided to do it on Laravel. But you can’t just go to some sites (redirect), I read that Dusc is like puppeeter.js. But no matter how much I searched and wriggled with queries on google, I can’t find anything on how to use a proxy with this wonderful package. Maybe one of you is more familiar with Dusc, or at least can direct me where to look?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Babichev, 2021-04-14
@REZ1DENT3

Using setCapability, you can set parameters for launching the browser.
You need to set an argument

--proxy-server= localhost:8080
in the chrome.switches section.
Example from stubs:
https://github.com/laravel/dusk/blob/d806611fa472d...
$options = (new ChromeOptions)->addArguments(collect([
    '--window-size=1920,1080',
])->unless($this->hasHeadlessDisabled(), function ($items) {
    return $items->merge([
        '--disable-gpu',
        '--headless',
    ]);
})->all());

return RemoteWebDriver::create(
    $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
    DesiredCapabilities::chrome()->setCapability(
        ChromeOptions::CAPABILITY, $options
    )
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question