PHP code example of rgasch / autoscraper

1. Go to this page and download the library: Download rgasch/autoscraper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rgasch / autoscraper example snippets




gasch\AutoScraper\AutoScraper;

$scraper = new AutoScraper();
$url = 'https://example.com/page-to-scrape';
$wishlist = ['Item 1', 'Item 2', 'Item 3'];

$result = $scraper->build($url, $wishlist);

if ($result) {
    echo "Scraping definition captured successfully.\n";
    $scraper->save('path/to/save/definition.json');
} else {
    echo "Failed to capture scraping definition.\n";
}



gasch\AutoScraper\AutoScraper;

$scraper = new AutoScraper();
$scraper->load('path/to/save/definition.json');

$url = 'https://example.com/another-page-to-scrape';
$result = $scraper->getResultSimilar($url);

if (!empty($result)) {
    echo "Scraped data:\n";
    print_r($result);
} else {
    echo "No data found.\n";
}

build($url, $wishlist)

save($filePath)

load($filePath)

getResultSimilar($url)

getCssSelector()
bash
php src/AutoScraperCaptureCommand.php
bash
php src/AutoScraperScrapeCommand.php