collab/module-scraper

Simple wrapper for the phpscraper library which provides Magento Service for scraping web pages.

1.0.1 2024-05-12 11:32 UTC

This package is auto-updated.

Last update: 2024-11-12 12:37:52 UTC


README

The Collab_Scraper module is a simple wrapper for PHPScraper which provides service for scraping data from websites.

PHPScraper is a versatile web-utility for PHP. Its primary objective is to streamline the process of extracting information from websites, allowing you to focus on accomplishing tasks without getting caught up in the complexities of selectors, data structure preparation, and conversion.

Basic usage

use Collab\Scraper\Service\ScraperService;
...
public function __construct(
    ScraperService $scraperService
) {
    $this->scraperService = $scraperService;
}
...
public function getScrapedData(): ?string
{
    $url = 'https://www.example.com';
    $data = $this->scraperService->go($url);
    echo $data->title; // Title of the page
    
    return $data;
}

Full documentation for PHPScraper can be found here.

Installation details

composer require collab/module-scraper
bin/magento setup:upgrade