Skip to content

Instantly share code, notes, and snippets.

@tomas-rampas
Last active January 1, 2018 20:08
Show Gist options
  • Save tomas-rampas/06edde87a2bc1a12dba06a7814d8e2c3 to your computer and use it in GitHub Desktop.
Save tomas-rampas/06edde87a2bc1a12dba06a7814d8e2c3 to your computer and use it in GitHub Desktop.
Powershell script for downloading jForex libraries. Needs Powershell 3.0 and above.
Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"
$jforex3Jnlp = 'jforex_3.jnlp'
$baseURL = 'http://platform.dukascopy.com/demo_3/'
$sourceJnlpURL = "$baseURL$jforex3Jnlp"
$appFrameworkXPath = '//jnlp/resources/extension[@name="AppFramework"]'
$jarsXPath = '//jnlp/resources/jar'
$outFileJForex3Jnlp = "$PSScriptRoot\jforex_3.jnlp"
$outFileLibs3Jnlp = "$PSScriptRoot\libs_3.jnlp"
$localLibSubDir = "jforex3libs"
Write-Host "CWD: $PSScriptRoot"
Write-Host "Downloading $sourceJnlpURL"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $sourceJnlpURL -OutFile $outFileJForex3Jnlp
[xml]$jforex3_jnlp = Get-Content $outFileJForex3Jnlp
$lib3JnlpURL = ($jforex3_jnlp.selectNodes($appFrameworkXPath) | select href).href
Write-Host "Downloading $lib3JnlpURL"
Invoke-WebRequest $lib3JnlpURL -OutFile $outFileLibs3Jnlp
[xml]$jforex3Libs_jnlp = Get-Content $outFileLibs3Jnlp
$jars = $jforex3Libs_jnlp.selectNodes($jarsXPath) | select href
New-Item -Force -ItemType Directory -path "$PSScriptRoot\$localLibSubDir"
foreach($jarHref in $jars.href){
Write-Host $baseURL$jarHref
$lib_href = $jarHref.split("/")[1]
Invoke-WebRequest "$baseURL$jarHref" -OutFile $PSScriptRoot\$localLibSubDir\$lib_href
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment