PHPackages                             riodevnet/elephscraper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. riodevnet/elephscraper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

riodevnet/elephscraper
======================

ElephScraper is a lightweight and PHP-native web scraping toolkit built using Guzzle and Symfony DomCrawler. It provides a clean and powerful interface to extract HTML content, metadata, and structured data from any website.

v1.0.0(1y ago)35MITPHP

Since Jul 3Pushed 1mo agoCompare

[ Source](https://github.com/riodevnet/elephscraper)[ Packagist](https://packagist.org/packages/riodevnet/elephscraper)[ RSS](/packages/riodevnet-elephscraper/feed)WikiDiscussions main Synced 2mo ago

READMEChangelog (3)Dependencies (3)Versions (2)Used By (0)

🐘 ElephScraper
==============

[](#-elephscraper)

[![Packagist](https://camo.githubusercontent.com/6d5a8bc8fa97fea4d0bceedb9e5bb1f10775c033b735be65ddcc9391d0620038/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696f6f6465762f656c657068736372617065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ioodev/elephscraper)[![PHP Version](https://camo.githubusercontent.com/aa5baae15929eddd449b609e0b50778c38899fd5138a0772ff90346ab11cd997/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e302d3737374242343f7374796c653d666c61742d737175617265)](composer.json)[![License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![CI](https://camo.githubusercontent.com/327a097f97c6a3b49dd94fa22308393e5acdf6d93c455760f91f2237afa8f898/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43492d476974487562253230416374696f6e732d3230383846463f7374796c653d666c61742d737175617265)](.github/workflows/ci.yml)

**ElephScraper** is a lightweight, PHP-native web scraping toolkit, built on top of [Guzzle](https://github.com/guzzle/guzzle) and [Symfony DomCrawler](https://symfony.com/doc/current/components/dom_crawler.html). This library provides a clean and powerful interface for extracting HTML, metadata, and structured data from any web page — or from an HTML string you already have yourself.

> Fast. Clean. Eleph-style scraping. 🐘⚡

Part of the [`ioodev`](https://github.com/ioodev) scraper ecosystem alongside [SnakyScraper](https://github.com/ioodev/snakyscraper) (Python) and [NodeScraper](https://github.com/ioodev/nodescraper) (Node.js) — three libraries with a similar API philosophy for three different language ecosystems.

> **Moving from `riodevnet/elephscraper`?** See [Migrating from v1.0](#-migrating-from-v10-riodevnetelephscraper)below — the namespace and package name changed in v1.1.0.

---

📋 Table of Contents
-------------------

[](#-table-of-contents)

- [Features](#-features)
- [Installation](#-installation)
- [Basic Usage](#%EF%B8%8F-basic-usage)
- [Error Handling](#-error-handling)
- [Request Options (Headers, Timeout, Proxy, etc.)](#-request-options-headers-timeout-proxy-etc)
- [Full API Reference](#-full-api-reference)
    - [Page Metadata](#-page-metadata)
    - [Open Graph &amp; Twitter Card](#-open-graph--twitter-card)
    - [Heading &amp; Text](#-heading--text)
    - [List](#-list)
    - [Images](#-images)
    - [Links](#-links)
    - [Custom DOM Filter](#-custom-dom-filter)
    - [Low-Level Access](#-low-level-access)
- [Project Structure](#-project-structure)
- [Testing &amp; Quality Tools](#-testing--quality-tools)
- [Migrating from v1.0 (`riodevnet/elephscraper`)](#-migrating-from-v10-riodevnetelephscraper)
- [Contributing](#-contributing)
- [Changelog](#-changelog)
- [License](#-license)

---

🚀 Features
----------

[](#-features)

- ✅ Extract metadata: title, description, keywords, author, charset, canonical, and more
- ✅ Full support for Open Graph, Twitter Card, CSRF token, and HTTP-equiv headers
- ✅ Extract headings, paragraphs, images, lists, and links — complete with `rel`, `nofollow`, etc. details
- ✅ Flexible `filter()` method with tag/class/ID-based selectors
- ✅ Can load from a URL **or** directly from an HTML string (`fromHtml()`) — no HTTP request needed, great for testing
- ✅ **Never throws a fatal error** — fetch/parse failures can always be checked via `isValid()` / `getError()`, or optionally thrown as an exception (`throwOnError`)
- ✅ Custom headers, timeout, proxy, cookies, and other Guzzle options via the `$options` parameter
- ✅ Safe return types: string, array, or associative array — always `null` (never a crash) when data isn't found
- ✅ Strict types &amp; full type-hints (PHP 8.0+) for a safer development experience
- ✅ Built on top of Guzzle + Symfony DomCrawler + CssSelector
- ✅ PHPUnit test suite, PHPStan level 6, and PHP-CS-Fixer (PSR-12) already set up

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require ioodev/elephscraper
```

> Requires PHP 8.0 or newer.

---

🛠️ Basic Usage
--------------

[](#️-basic-usage)

```
