1. Perl
  2. Module
  3. here

Selenium::Chrome - JavaScript - enabled web scraping using Chrome

Selenium::Chrome allows you to use Chrome for JavaScript-enabled web scraping. Selenium::Chrome is an extension of Selenium::Remote::Driver for Chrome. You can use it by installing Selenium::Remote::Driver.

When running on Windows, Mac

# When running on Windows, Mac
use Selenium::Chrome;
my $driver = Selenium::Chrome->new;
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->shutdown_binary();

When executing headless when there is no GUI screen such as Unix/Linux

If you want to execute on the CUI screen when there is no GUI environment, execute headless as follows.

# When executing headless when there is no GUI screen such as Unix/Linux
use Selenium::Chrome;
my $driver = Selenium::Chrome->new(
  extra_capabilities => {
    'goog: chromeOptions' => {
      args => ['headless', 'disable-gpu', 'window-size = 1920,1080', 'no-sandbox']
    }
  }
);
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->shutdown_binary();

If the following error occurs, please execute headless with the above option.

Could not create new session: unknown error: Chrome failed to start: exited abnormally.

(unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location/usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) At access.pl line 79.

Preparation of execution environment

Chrome browser and Chrome Driver are required as an execution environment for JavaScript-compatible web scraping using Selenium::Chrome. Chrome Driver is software for operating Chrome itself. The environment construction procedure differs depending on the OS, refer to the following.

It's a good idea to match Chrome browser and Chrome Driver versions as much as possible to avoid binary compatibility issues.

For Unix/Linux

Install Chrome Driver - Cent OS 7

Install Google Chrome - CentOS 7

For other UNIX/Linux such as Ubuntu, Debian, FreeBSD, try searching for the Chrome browser itself and how to install the Chrome Driver. Let's do it.

Windows

On the SPA site, the environment construction procedure of performing GUI test with Selenium::Remote::Driver will be helpful.

Active Perl but Strawberry Perl I think it's okay.

For Mac

Using Selenium from Perl The environment construction procedure will be helpful.

Related Informatrion