PHP code example of userforce / scraper

1. Go to this page and download the library: Download userforce/scraper 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/ */

    

userforce / scraper example snippets


'providers' => [
    ...
    UserForce\Scraper\ScraperServiceProvider::class,
],

'aliases' => [
    ...
    'Scraper' => UserForce\Scraper\Facade\Scraper::class,
],

use Scraper;

$result = Scraper::find($config);

$config = [
    'ibmachine' => [
        'url' => 'https://ibmachine.com/machine',
        'regex' => [
            'name' => 'machine\/view\/[0-9]{1,7}" itemprop="name">\s*(<span.*\/span>)?\s*(.*)\s*<\/a>',
            'links' => [
                'url' => 'href=\"(http.*machine\/view\/[\d]{1,7})\"\sitemprop'
            ]
        ]
    ]
];

$result = Scraper::find($config);

$result->get();

array:1 [▼
  "ibmachine" => array:2 [▼
    "name" => array:3 [▼
      0 => array:20 [▶]
      1 => array:20 [▶]
      2 => array:20 [▼
        0 => "Alesatrice TOS Whn q 13 anno 2001"
        1 => "CURVATRICE TAURING mod. DELTA 60 CNC"
        2 => "Calandre idrauliche 3 rulli"
        ...
      ]
    ]
    "links" => array:1 [▼
      "url" => array:2 [▼
        0 => array:20 [▶]
        1 => array:20 [▶]
      ]
    ]
  ]
]