aboutsummaryrefslogtreecommitdiff
path: root/bin/crawl.php
blob: e9a6218cac2e5ba4b6e9489a7befbcf5926b5ea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env php
<?php
namespace phinde;
require_once __DIR__ . '/../src/init.php';

if ($argc < 2) {
    echo "No URL given\n";
    exit(1);
}

$url = $argv[1];
$url = Helper::addSchema($url);
if (!Helper::isUrlAllowed($url)) {
    echo "Domain is not allowed; not crawling\n";
    exit(2);
}

try {
    $crawler = new Crawler();
    $crawler->crawl($url);
} catch (\Exception $e) {
    echo $e->getMessage() . "\n";
    exit(10);
}
?>