Skip to content

Commit

Permalink
Update scrape.php
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <[email protected]>
  • Loading branch information
ghostwriter committed Jan 3, 2025
1 parent 37a4eb5 commit cb99586
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scrape.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@
do {
$response = $http->get($api, [
'category' => 'african-american',
'page' => $page,
'page' => --$page,
]);

if ($response->failed()) {
fwrite(STDERR, 'Failed to fetch data from the API' . PHP_EOL);
fwrite(STDERR, $response->body() . PHP_EOL);
exit(1);
}

$crawler = new Crawler($response->body());
$crawler->filter('div.results-row')
->each(static function (Crawler $crawler) {
Expand Down Expand Up @@ -147,5 +154,7 @@
'hash'=> $hash,
], $payload);
});
} while (--$page);

sleep(3);
} while ($page > 1);
})(\implode(DIRECTORY_SEPARATOR,[__DIR__ , 'vendor','autoload.php']));

0 comments on commit cb99586

Please sign in to comment.