PHP code example of fozbek / scrawler
1. Go to this page and download the library: Download fozbek/scrawler 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/ */
fozbek / scrawler example snippets
$url = 'https://google.com';
$schema = [
'title' => 'title',
'a-tags' => [
'list-selector' => 'a',
'content' => [
'text' => 'a',
'url' => 'a@href',
],
],
];
$scrawler = new \Scrawler\Scrawler();
$response = $scrawler->scrape($url, $schema);
echo json_encode($response);
$schema = [
'forum-title' => '.p-body-header .p-title-value'
];
$schema = [
'threads' => [
'list-selector' => '.structItem--thread',
'content' => [
'thread-title' => '.structItem-title',
'thread-url' => '.structItem-title a@href',
'last-update-date' => '.structItem-latestDate',
]
]
];
$schema = [
'login-page' => [
'request-selector' => 'a.p-navgroup-link--logIn@href',
'base-url' => 'https://xenforo.com',
'content' => [
'title' => 'title',
],
],
];
$schema = [
'title' => 'title',
'threads' => [
'list-selector' => '.structItem--thread',
'content' => [
'thread-detail' => [
'request-selector' => '.structItem-title a@href',
'base-url' => 'https://xenforo.com',
'content' => [
'thread-content' => '.message-body .bbWrapper',
],
],
],
]
];