Installation

Installation

Larascraper needs two things: the PHP package through Composer, and a few Node packages the internal Puppeteer script relies on. Composer cannot install the Node side for you, so it is a two step install. If you only ever use the HTTP driver, step two is optional.

1. The PHP package

composer require edulazaro/larascraper

The HTTP driver uses Laravel's HTTP client. If Guzzle is not already installed:

composer require guzzlehttp/guzzle

2. The Node side

php artisan larascraper:install

That single command installs the Node packages and the Chrome binary Puppeteer needs. Nothing else is required.

Prefer to do it by hand? Then skip the command and run exactly what it would have run:

npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
npx puppeteer browsers install chrome

Options:

--publish Also publish scraper.cjs to the project root, so you can customize the Node runner.
--no-npm Skip npm install and just print the command to run.
--no-browser Skip downloading Chrome. Use it when you provide a system Chrome through PUPPETEER_EXECUTABLE_PATH.
--captcha Also install the optional OCR packages (tesseract.js, jimp) used by solveCaptcha(). Left out by default so projects that never solve a captcha stay lean.

Run it where the scraper runs

Run larascraper:install in the same environment the scraper executes in, for instance inside your Docker or Sail container, so Chrome lands in that environment's cache.

The Chrome step is not redundant. When node_modules is already present, for example mounted into a container from the host, Puppeteer's automatic Chrome download is skipped, so the command installs the binary explicitly. Recreating a container without a volume for it means running the command again.

If the Node packages are missing, the scraper fails fast with a message that says so, rather than failing obscurely somewhere else.

3. The config file, when you need it

php artisan vendor:publish --tag=larascraper-config

Everything works without it. Publish it when you want a pool of proxies, throttling rules, or to bump the HTTP driver's user agent. See Configuration and Proxies and throttling.

System binaries for the PDF engines

These are OS packages, not Composer dependencies, so add them to your image if you read PDFs. They are also listed under suggest in the package's composer.json.

Feature Binary Debian/Ubuntu
text(), the default gs engine gs apt-get install ghostscript
text('poppler') and page rasterization for vision() pdftotext, pdftoppm apt-get install poppler-utils
vision('tesseract') tesseract apt-get install tesseract-ocr

Note that vision('ai') still needs poppler-utils: it rasterizes each page with pdftoppm before sending it to the vision model.

Node through NVM, and scheduled tasks

If Node is installed through NVM, a scheduled task will probably not find it, because cron runs a non-interactive shell. Add this at the top of ~/.bash_profile:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Then source ~/.bash_profile. In general NVM is not a good fit for production; a system Node is one less moving part.

Checking the install

php artisan list:scrapers

If that runs, the PHP side is in place. For the Node side, write a one line scraper and run it against any JavaScript-heavy page through Tinker. See Commands and testing.