Skip to content

Instantly share code, notes, and snippets.

@catwhocode
Last active June 7, 2022 08:59
Show Gist options
  • Save catwhocode/e5290de25af2d2b32833777c094bec6c to your computer and use it in GitHub Desktop.
Save catwhocode/e5290de25af2d2b32833777c094bec6c to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use DiDom\Document;
$client = new Client();
$url = 'https://www.bca.co.id/id/informasi/kurs';
$userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36';
$headers = [
'User-Agent' => $userAgent,
];
$response = $client->get($url, [
'headers' => $headers,
]);
$html = (string) $response->getBody();
$document = new Document($html);
$elem = $document->find('p[rate-type="ERate-buy"]');
echo $elem[0]->html();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment