This commit is contained in:
2020-10-06 01:11:23 +05:00
parent 608522f148
commit 32888bd5b2
3 changed files with 11 additions and 4 deletions

View File

@@ -26,9 +26,8 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command('scrape:mihaaru')->everyFiveMinutes()
->pingOnSuccess(env('APP_URL') . "/api/ping/mihaaru")
->runInBackground();
->runInBackground()
->pingOnSuccess(env('APP_URL') . "/api/ping/mihaaru");
$schedule->command('scrape:sun')->everyFiveMinutes()
->runInBackground()

View File

@@ -18,7 +18,10 @@ class AvasService
$articlesitems = [];
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
foreach ($articles as $article) {
$articlesitems[] = (new AvasScraper)->extract($article["link"], $article["date"]);
$scraped_article = (new AvasScraper)->extract($article["link"], $article["date"]);
if (!is_null($scraped_article)) {
$articlesitems[] = $scraped_article;
}
}
return $articlesitems;

View File

@@ -30,6 +30,11 @@ class AvasScraper
$this->image = $crawler->filter('figure img')->first()->attr('src');
}
if($crawler->filter('.post_content p')->count() == 0)
{
return;
}
$crawler->filter('.post_content p')->each(function ($node) {
$this->content[] = preg_replace("/[a-zA-Z]/","",$node->text());
});