balkon-developer/table-scraper

Table scrapers with unmerge cell.

dev-dev 2020-10-13 08:41 UTC

This package is not auto-updated.

Last update: 2024-04-24 10:55:29 UTC


README

Build Status Codecov Code Coverage

PHP Table Scraper

a package to help you scraping one or some tables in a website and automatically unmerge the cells. The result, you get the data as Collection. It's useful for me, I hope it will helpful for you so.

Installation

composer require balkon-developer/table-scraper

How to use

  • Get a table with css selector, the result is ScrapeTable class
use BalkonDeveloper\TableScraper\Scrape;

$url = 'https://your-target-website';
$scrape = Scrape::fromUrl($url);

$tableSelector = '.target';
$table = $scrape->table($tableSelector);

// var_dump($table)
  • Get multiple tables with css selector, the result is Collection of ScrapeTable class
use BalkonDeveloper\TableScraper\Scrape;

$url = 'https://your-target-website';
$scrape = Scrape::fromUrl($url);

$tableSelector = '.target';
$tables = $scrape->tables($tableSelector);

// var_dump($tables)
  • Get all tables, the result is Collection of ScrapeTable class
use BalkonDeveloper\TableScraper\Scrape;

$url = 'https://your-target-website';
$scrape = Scrape::fromUrl($url);

$tables = $scrape->tables();

// var_dump($tables)

Result as ScrapeTable

Result as Collection

Helpers