Created
October 3, 2022 16:43
-
-
Save SeidChr/355dd158841b4bacb1644d30682b0325 to your computer and use it in GitHub Desktop.
Extracts information about parked cars from mobile.de and calculates an index (higher is better) based on milage, age and price
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
# https://www.mobile.de/svc/my/parking-list/?lang=de | |
$j | 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 | |
$index = 0 | |
try { | |
$index = ($kmIndex/$km)+($priceIndex/$price)+($ageIndex/$age)+($kmAIndex/$kmA) | |
} 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