This commit is contained in:
2020-10-02 02:54:14 +05:00
parent f738b107fd
commit 9aa8cf29a7

View File

@@ -27,7 +27,7 @@ class DhuvasScraper
$this->title = $node->text(); $this->title = $node->text();
}); });
// Checking for two types of article patterns // Checking for three types of article patterns
if ($crawler->filter('.elementor-widget-container > div.normal_text_dv')->count() > 0) { if ($crawler->filter('.elementor-widget-container > div.normal_text_dv')->count() > 0) {
$crawler->filter('.elementor-widget-container > div.normal_text_dv, div.normal_text_dv > p')->each(function ($node) { $crawler->filter('.elementor-widget-container > div.normal_text_dv, div.normal_text_dv > p')->each(function ($node) {
@@ -37,21 +37,21 @@ class DhuvasScraper
} }
$this->content[] = preg_replace("/[a-zA-Z]/", "", $node->text()); $this->content[] = preg_replace("/[a-zA-Z]/", "", $node->text());
}); });
} else if ($crawler->filter('.elementor-widget-container p[dir*="rtl"]')->count() > 0) {
$crawler->filter('.elementor-widget-container p[dir*="rtl"]')->each(function ($node) {
$this->content[] = preg_replace("/[a-zA-Z]/", "", $node->text());
});
} else { } else {
$crawler->filter('.elementor-widget-container > p')->each(function ($node) { $crawler->filter('.elementor-widget-container > p')->each(function ($node) {
$this->content[] = preg_replace("/[a-zA-Z]/", "", $node->text()); $this->content[] = preg_replace("/[a-zA-Z]/", "", $node->text());
}); });
} }
// Checking if the author of the article exists
if ($crawler->filter('span[class*="elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-author"]')->count() == 1) { if ($crawler->filter('span[class*="elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-author"]')->count() == 1) {
$this->author = $crawler->filter('span[class*="elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-author"]')->first()->text(); $this->author = $crawler->filter('span[class*="elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-author"]')->first()->text();
} }
//Remove all the alphabets from string //Remove all the alphabets from string
//preg_replace("/[a-zA-Z]/", "",$string); //preg_replace("/[a-zA-Z]/", "",$string);
return [ return [