Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function Get-SteamWishList {
<#
.SYNOPSIS
Get wishlist of Steam user
.DESCRIPTION
Get the wishlist of any public Steam user accounts.
.EXAMPLE
Get-SteamWishList user01
Get the wishlist for Steam user account 'user01'
.NOTES
Remember that this function will only ever be able to get
the wishlist from Steam accounts where the wishlist is made public.
Author: Øyvind Kallstad
Date: 02.01.2016
Version: 1.0
.LINK
https://communary.wordpress.com/
#>
#requires -Version 3
[CmdletBinding()]
param (
[Parameter(Position = 1, Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $SteamUserId
)
$url = "http://steamcommunity.com/id/$($SteamUserId)/wishlist"
$steamWishList = Invoke-WebRequest -Uri $url
$steamWishList.ParsedHtml.body.getElementsByClassName('wishlistRowItem') | ForEach-Object {
$childNodes = $_.childNodes
$name = $childNodes | Where-Object {$_.tagName -eq 'H4'} | Select-Object -ExpandProperty InnerText
$added = $childNodes | Where-Object {$_.className -eq 'wishlist_added_on ellipsis'} | Select-Object -ExpandProperty InnerText
$rank = ($childNodes | Where-Object {$_.className -eq 'wishlistRankCtn'}).textContent
$itemPriceData = ($childNodes | Where-Object {$_.className -eq 'gameListPriceData'}).childNodes
$itemDiscountPercent = (($itemPriceData | Where-Object {$_.className -eq 'discount_block discount_block_inline'}).childNodes | Where-Object {$_.className -eq 'discount_pct'}).textContent
if ($itemDiscountPercent) {
$itemOriginalPrice = ((($itemPriceData | Where-Object {$_.className -eq 'discount_block discount_block_inline'}).childNodes | Where-Object {$_.className -eq 'discount_prices'}).childNodes | Where-Object {$_.className -eq 'discount_original_price'}).textContent
$itemFinalPrice = ((($itemPriceData | Where-Object {$_.className -eq 'discount_block discount_block_inline'}).childNodes | Where-Object {$_.className -eq 'discount_prices'}).childNodes | Where-Object {$_.className -eq 'discount_final_price'}).textContent
}
else {
$itemOriginalPrice = ($itemPriceData | Where-Object {$_.className -eq 'price'}).textContent
$itemFinalPrice = $null
}
Write-Output (,([PSCustomObject] [Ordered] @{
Rank = $rank
Name = $name
Discount = $itemDiscountPercent
OriginalPrice = $itemOriginalPrice
FinalPrice = $itemFinalPrice
Added = $added
}))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment