Update AvasScraper.php
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Scrapers;
|
||||
|
||||
use Goutte\Client;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Exception;
|
||||
|
||||
class AvasScraper
|
||||
{
|
||||
@@ -20,18 +22,16 @@ class AvasScraper
|
||||
|
||||
public function extract($url, $date)
|
||||
{
|
||||
|
||||
try {
|
||||
$crawler = $this->client->request('GET', $url);
|
||||
|
||||
$title = $crawler->filter('h1')->first()->text();
|
||||
|
||||
if($crawler->filter('figure img')->count() > 0)
|
||||
{
|
||||
if ($crawler->filter('figure img')->count() > 0) {
|
||||
$this->image = $crawler->filter('figure img')->first()->attr('src');
|
||||
}
|
||||
|
||||
if($crawler->filter('.post_content p')->count() == 0)
|
||||
{
|
||||
if ($crawler->filter('.post_content p')->count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ class AvasScraper
|
||||
$crawler->filter('div[class*="border-t border-grey-light border-dotted mt-7 py-3"] a')->each(function ($node) {
|
||||
|
||||
//Removing the show more tags button
|
||||
if($node->text() == "+")
|
||||
{
|
||||
if ($node->text() == "+") {
|
||||
return;
|
||||
}
|
||||
$this->topics[] = [
|
||||
@@ -54,8 +53,7 @@ class AvasScraper
|
||||
|
||||
|
||||
|
||||
if($crawler->filter('div[class*="font-waheed text-grey ml-3 pl-3 text-lg border-l border-grey border-dotted"] a')->count() == 1)
|
||||
{
|
||||
if ($crawler->filter('div[class*="font-waheed text-grey ml-3 pl-3 text-lg border-l border-grey border-dotted"] a')->count() == 1) {
|
||||
$this->author = $crawler->filter('div[class*="font-waheed text-grey ml-3 pl-3 text-lg border-l border-grey border-dotted"] a')->first()->text();
|
||||
}
|
||||
|
||||
@@ -74,5 +72,8 @@ class AvasScraper
|
||||
'author' => $this->author,
|
||||
'topics' => $this->topics
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user