From zyrex, 5 Years ago, written in PowerShell.
Embed
  1.  
  2. [xml]$Weather = Get-Content "C:\Users\Morten\Downloads\GetMeasuredWeatherData.xml"
  3.  
  4. $IDLygna = "206"
  5. $IDBekkehallum = "207"
  6.  
  7. $EndResult = @()
  8. $IDs = "206","207"
  9.  
  10. Foreach ($place in $IDs) {
  11.     $Location = $Weather.d2LogicalModel.payloadPublication.siteMeasurements | Where-Object { $_.measurementsitereference.id -eq $place }
  12.  
  13.     $LocationAirTemp = ($Location.measuredValue | Where-Object {$_.index -eq "101"}).innertext + " °C"
  14.     $LocationRoadTemp = ($Location.measuredValue | Where-Object {$_.index -eq "801"}).innertext + " °C"
  15.     $LocationPrecipitation = ($Location.measuredValue | Where-Object {$_.index -eq "2501"}).innertext + " mm/h"
  16.  
  17.     $Place = $place -replace "206","Lygna" -replace "207","Bekkehallum"
  18.     $Resultname = new-object psobject -Property @{
  19.         Lokasjon = $place
  20.         Lufttemperatur = $LocationAirTemp
  21.         Veibanetemperatur = $LocationRoadTemp
  22.         Nedbørintensitet = $LocationPrecipitation
  23.         }
  24.         $EndResult += $ResultName
  25.     }
  26.  
  27.  
  28. $EndResult
  29.  
  30.  
  31. $a = "<style>"
  32. $a = $a + "BODY{background-color:#FF8000;}"
  33. $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
  34. $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#408080}"
  35. $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
  36. $a = $a + "</style>"
  37. $a = $a + '<meta charset="UTF-8">'
  38.  
  39. $b = "<center>"
  40. $b = $b + "<b><h2>Værstatistikk</b></h2>"
  41.  
  42. $code = $EndResult|ConvertTo-Html -Head $a -Body $b
  43. $code | Out-File C:\temp\mesta.html
  44.  
  45.  
  46.  
  47.  
  48. Write-host -fore Yellow "## Starting FTP upload.."
  49. $File = "C:\temp\mesta.html";
  50. $ftp = "ftp://morten:[email protected]//home/httpd/sites/zyrex.org/temp/mesta.html";
  51.  
  52. $webclient = New-Object -TypeName System.Net.WebClient;
  53. $uri = New-Object -TypeName System.Uri -ArgumentList $ftp;
  54.  
  55. Write-Host -fore Yellow "## Uploading $File...";
  56. $webclient.UploadFile($uri, $File);
  57.