format('Y-m-d H:i:s'); // Döviz kurları $response = Http::withHeaders([ 'User-Agent' => 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10', 'Accept-Language' => 'en' ])->get('https://kur.doviz.com'); // DOM işlemleri için veri çekme $dom = new \DOMDocument(); @$dom->loadHTML($response->body()); $xpath = new \DOMXPath($dom); // Döviz kurlarını çekme $elements = $xpath->query("//*[@data-socket-key]"); foreach ($elements as $element) { $name = $element->getAttribute('data-socket-key'); $type = $element->getAttribute('data-socket-attr'); $value = $this->virgulToNokta(trim($element->nodeValue)); if (trim($name) !== '') { if ($name == "JPY") $value = $value / 100; if ($type == "bid") $data[$name]['Buying'] = $value; if ($type == "ask") $data[$name]['Selling'] = $value; if ($type == "c") $data[$name]['Change'] = $value; $data[$name]['Type'] = "Currency"; } } // AZN kuru için $aznResponse = Http::get('https://wise.com/tr/currency-converter/azn-to-try-rate?amount=1'); preg_match('/(\d+\.\d+)\s+TRY/', $aznResponse->body(), $matches); if (isset($matches[1])) { $data['AZN'] = [ 'Buying' => $matches[1], 'Selling' => $matches[1], 'Change' => "0.00", 'Type' => "Currency" ]; } // Altın kurları $goldResponse = Http::get('https://altin.doviz.com'); // ... Altın kurları için benzer DOM işlemleri ... // JSON dosyasını kaydet Storage::put('currency/today.json', json_encode($data, JSON_UNESCAPED_UNICODE)); return $data; } private function virgulToNokta($text) { $text = str_replace(".", "", $text); $text = str_replace(",", ".", $text); $text = str_replace("%", "", $text); return $text; } }