Mihaaru scraper support

This commit is contained in:
2020-08-10 03:21:56 +05:00
parent 5af5f75175
commit fd2fc06115
4 changed files with 30 additions and 6 deletions

View File

@@ -15,15 +15,15 @@ class MihaaruService extends Client
{
$articles = $this->get("https://mihaaru.com/rss")["channel"]["item"];
$articlesitems = [];
$emihaaru = new MihaaruScraper();
$scraper = new MihaaruScraper();
foreach ($articles as $article) {
$link = $article['link'];
$date = $article['pubDate'];
$guid = $article['guid'];
$articlesitems[] = $emihaaru->extract($link, $date, $guid);
$articlesitems[] = $scraper->extract($link, $date, $guid);
}
return $articlesitems;

View File

@@ -19,7 +19,7 @@ class MihaaruScraper
$this->client = new Client;
}
public function extract($url)
public function extract($url, $date = null, $guid = null)
{
$crawler = $this->client->request('GET', $url);
@@ -66,6 +66,8 @@ class MihaaruScraper
'image' => $this->image,
'content' => $this->content,
'url' => $url,
'date' => $date,
'guid' => $guid,
'author' => $this->author,
'topics' => $this->tags,
];