Bug Fixes and thiladhun scraper intergration
This commit is contained in:
@@ -11,7 +11,7 @@ class MihaaruScraper
|
||||
protected $title;
|
||||
protected $content;
|
||||
protected $image;
|
||||
protected $tags = [];
|
||||
protected $topics = [];
|
||||
protected $author;
|
||||
|
||||
public function __construct()
|
||||
@@ -25,13 +25,11 @@ class MihaaruScraper
|
||||
$crawler = $this->client->request('GET', $url);
|
||||
|
||||
$crawler->filter('h1')->each(function ($node) {
|
||||
$title = $node->text();
|
||||
$this->title = $title;
|
||||
$this->title = $node->text();
|
||||
});
|
||||
|
||||
$crawler->filter('.container img')->eq(3)->each(function ($node) {
|
||||
$image = $node->attr('src');
|
||||
$this->image = $image;
|
||||
$this->image = $node->attr('src');
|
||||
});
|
||||
|
||||
$crawler->filter('.by-line address')->each(function ($node) {
|
||||
@@ -49,7 +47,7 @@ class MihaaruScraper
|
||||
|
||||
$crawler->filter('.article-tags')->each(function ($node) {
|
||||
|
||||
$this->tags[] = [
|
||||
$this->topics[] = [
|
||||
"name" => $node->text(),
|
||||
"slug" => str_replace("https://mihaaru.com/", "", $node->attr('href'))
|
||||
];
|
||||
@@ -57,7 +55,7 @@ class MihaaruScraper
|
||||
|
||||
//Remove all the alphabets from string
|
||||
//preg_replace("/[a-zA-Z]/", "",$string);
|
||||
$data = [
|
||||
return [
|
||||
'source' => 'Mihaaru',
|
||||
'title' => $this->title,
|
||||
'og_title' => $crawler->filter('meta[property*="og:title"]')->first()->attr('content'),
|
||||
@@ -67,9 +65,7 @@ class MihaaruScraper
|
||||
'date' => $date,
|
||||
'guid' => $guid,
|
||||
'author' => $this->author,
|
||||
'topics' => $this->tags,
|
||||
'topics' => $this->topics
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user