- Facebook OAuth login
- AstroCrawler is a tool to crawl this website's daily astro fortunes
It is very simpler to use.
This sample crawl today's fortune of 12 astros and return a collection
of AstroFortune
models.
$service = new AstroCrawlerService();
$models = $service->crawl();
To save them into DB, you can achieve it by easily using each
provided by collection
.
$models->each(funciton ($model) {
$model->save();
});
There are 3 types of this crawler
- fortune of a date in this week
- fortune of this week
- fortune of this month
To set the type of fortune to crawl
$models = $service->setType(2)->crawl();
By default, this service will crawl all 12 astros, but we can specific which astros to crawl by these 2 functions.
AstroCrawlerService
provides const variables to easily choose astros.
use AstroCrawlerService as ACS
$models = $service->setType(2)->setAstro(ACS::GEMINI)->crawl();
$models = $service->setType(2)->setAstros([0, 2, 4])->crawl();
This function only be useful when "fortune of a date" (type 0)
$date = today()->format('Y-m-d');
$models = $service->setType(0)->setDate($date)->crawl();
Select what columns to crawl like SQL language. By default, this service will crawl all 4 columns
general: 整體運勢
love: 愛情運勢
career: 事業運勢
wealth: 財運運勢
$models = $service->setType(2)->select(['love', 'general'])->crawl();