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
+4 -1
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;
+5
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());
});