Skip to content

Instantly share code, notes, and snippets.

@SeidChr
Last active October 13, 2022 15:00
Show Gist options
  • Save SeidChr/c3ebd0f3d26b8d64707ffa3a9b8d6cea to your computer and use it in GitHub Desktop.
Save SeidChr/c3ebd0f3d26b8d64707ffa3a9b8d6cea to your computer and use it in GitHub Desktop.
# https://www.mobile.de/svc/my/parking-list/?lang=de
Get-Clipboard | ConvertFrom-Json |% items |? status -eq OK |% {
$now = Get-Date
$kmIndex = 1000000
$priceIndex = 700000
$ageIndex = 100
$kmAIndex = 300000
} {
$month,$year = $_.ad.attr.fr?.split("/") ?? 0,0
$km = [int][Regex]::Replace($_.ad.attr.ml, "[^\d]", '')
$age = 0
$kmA = 0
if ($month -and $year) {
$age = (( 12 * $now.Year + $now.Month ) - ( 12 * $year + $month )) / 12
$kmA = $km / $age
}
$id = $_.parking.adid
$price = [int]$_.parking.price.amount
$featureMap = @{
#"Markise" = 50
"Tempomat" = 100
"Solaranlage" = 100
#"WC" = 100
}
$featureIndex = $_.ad.features |% { $featureMap.$_ } | Measure-Object -sum |% sum
$index = 0
try {
$index = ($kmIndex/$km)+($priceIndex/$price)+($ageIndex/$age)+($kmAIndex/$kmA)+$featureIndex
} catch {}
[pscustomobject]@{
Price = $price
km = $km
"km/A" = [int]$kmA
Age = [Math]::Round($age,2)
Index = [Math]::Round($index,2)
Link = "https://suchen.mobile.de/fahrzeuge/details.html?id=$id"
Make = $_.ad.make.localized
}
} | Sort Index -Descending | FT -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment