From 68940c00b9598de5a50bc5c75bb90f63a462d811 Mon Sep 17 00:00:00 2001 From: Mohamed jinas Date: Sat, 13 Jan 2024 05:08:37 +0500 Subject: [PATCH] proxy feshun --- app/Services/FeshunService.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Services/FeshunService.php b/app/Services/FeshunService.php index 31ccdc6..e2c65ca 100644 --- a/app/Services/FeshunService.php +++ b/app/Services/FeshunService.php @@ -14,7 +14,12 @@ class FeshunService extends Client */ public function scrape(): array { - $articles = Http::get("https://feshun.mv/wp-json/wp/v2/posts")->json(); + $proxyOptions = [ + 'proxy' => config('karudhaas.proxy.host'), + ]; + + $articles = Http::withOptions($proxyOptions) + ->get("https://feshun.mv/wp-json/wp/v2/posts")->json(); $articlesitems = []; foreach ($articles as $article) { @@ -22,11 +27,13 @@ class FeshunService extends Client '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("

",str_replace("

","",$article["content"]["rendered"])), + 'image' => Http::withOptions($proxyOptions) + ->get("https://feshun.mv/wp-json/wp/v2/media?include=" . $article["featured_media"])->json()[0]["guid"]["rendered"], + 'content' => explode("

", str_replace("

", "", $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"], + 'author' => Http::withOptions($proxyOptions) + ->get("https://feshun.mv/wp-json/wp/v2/users?include=" . $article["author"])->json()[0]["name"], 'guid' => basename($article["link"]), 'topics' => [ [