Last active
June 7, 2022 08:59
-
-
Save catwhocode/e5290de25af2d2b32833777c094bec6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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