Popularity
5.0
Growing
Activity
5.3
-
496
17
72

Description

An oppinated & limited way to access the web using PHP. This is an extension to provide an alternative interface to Goutte. The examples tell the story much better. Have a look!

Monthly Downloads: 3,602
Programming language: PHP
License: GNU General Public License v3.0 or later

PHP Scraper alternatives and similar libraries

Based on the "Scraping" category.
Alternatively, view PHP Scraper alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of PHP Scraper or a related project?

Add another 'Scraping' Library

README

[PHP Scraper](header.jpg)

PHP Scraper

An opinionated & limited way to scrape the web using PHP. The main goal is to get stuff done instead of getting distracted with xPath selectors, preparing data structures, etc. Instead, you can just "go to a website" and get an array with all details relevant to your scraping project.

Under the hood, it uses Goutte and a few other packages. See composer.json.

Sponsors

This project is sponsored by:

Want to sponsor this project? Contact me.

Examples

Here are a few impressions on the way the library works. More examples are on the project website.

Get the Title of a Website

All scraping functionality can be accessed either as a function call or a property call. On the example of title scraping this would like like this:

$web = new \spekulatius\phpscraper();

$web->go('https://google.com');

// Returns "Google"
echo $web->title;

// Also returns "Google"
echo $web->title();

Scrape the Images from a Website

Scraping the images including the attributes of the img-tags:

$web = new \spekulatius\phpscraper();

/**
 * Navigate to the test page.
 *
 * This page contains twice the image "cat.jpg".
 * Once with a relative path and once with an absolute path.
 */
$web->go('https://test-pages.phpscraper.de/meta/lorem-ipsum.html');

var_dump($web->imagesWithDetails);
/**
 * Contains:
 *
 * [
 *     'url' => 'https://test-pages.phpscraper.de/assets/cat.jpg',
 *     'alt' => 'absolute path',
 *     'width' => null,
 *     'height' => null,
 * ],
 * [
 *     'url' => 'https://test-pages.phpscraper.de/assets/cat.jpg',
 *     'alt' => 'relative path',
 *     'width' => null,
 *     'height' => null,
 * ]
 */

See the full documentation for more information and examples.