feshun fix
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Services\Scrapers\FeshunScraper;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class FeshunService extends Client
|
||||
{
|
||||
@@ -13,12 +14,27 @@ class FeshunService extends Client
|
||||
*/
|
||||
public function scrape(): array
|
||||
{
|
||||
$articles = $this->get("https://feshun.mv/feed")["channel"]["item"];
|
||||
$articles = Http::get("https://feshun.mv/wp-json/wp/v2/posts")->json();
|
||||
|
||||
$articlesitems = [];
|
||||
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
|
||||
foreach ($articles as $article) {
|
||||
$articlesitems[] = (new FeshunScraper)->extract($article['link'], $article['pubDate']);
|
||||
$articlesitems[] = [
|
||||
'source' => 'Feshun',
|
||||
'title' => $article["title"]["rendered"],
|
||||
'og_title' => $article["title"]["rendered"],
|
||||
'image' => Http::get("https://feshun.mv/wp-json/wp/v2/media?include=".$article["featured_media"])->json()[0]["guid"]["rendered"],
|
||||
'content' => explode("<p>",preg_replace("/[a-zA-Z]/", "", $article["content"]["rendered"])),
|
||||
'date' => Carbon::parse($article["date"])->format("Y-m-d H:i:s"),
|
||||
'url' => $article["link"],
|
||||
'author' => Http::get("https://feshun.mv/wp-json/wp/v2/users?include=".$article["author"])->json()[0]["name"],
|
||||
'guid' => basename($article["link"]),
|
||||
'topics' => [
|
||||
[
|
||||
"name" => "ވަކި މަޢުލޫއެއް ނޭންގެ",
|
||||
"slug" => "no-specific-topic"
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return $articlesitems;
|
||||
|
||||
Reference in New Issue
Block a user