Created
August 6, 2023 13:54
-
-
Save Y-Koji/7a9fe20fb88a34b1d13047c663815a14 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
function Get-SP500 { | |
$res = Invoke-WebRequest -Uri 'https://www.bing.com/search?q=sp500' | |
$content = $res.Content | |
$m = [Regex]::Match($content, '<span class="fin_scibr">([\d\.,]+)</span>') | |
$m.Groups[1].Value | |
} | |
function Get-USDJPY { | |
$res = Invoke-WebRequest -Uri 'https://www.bing.com/search?q=usdjpy' | |
$content = $res.Content | |
$m = [Regex]::Match($content, '<div class="b_focusTextSmall curr_totxt">([\d\.]+) 日本 円</div>') | |
$m.Groups[1].Value | |
} | |
while ($true) { | |
$date = Get-Date -Format 'yyyy/MM/dd HH:mm:ss' | |
$header = [string]::Format('[{0}]', $date) | |
Start-Sleep -Seconds 1 | |
$sp500 = Get-SP500 | |
Start-Sleep -Seconds 1 | |
$usdJpy = Get-USDJPY | |
Write-Host '' | |
Write-Host $header | |
Write-Host 'SP500:' $sp500 | |
Write-Host 'USDJPY: ' $usdJpy | |
Write-Host '' | |
Pause | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment