View Steam wishlists with PowerShell

With Steam having frequent sales, I find I often pop into my own, as well as my friends wishlists to plan purchases. Wouldn’t it be great to be able to list a wishlist from the PowerShell console?

I created a small function to do just that. Just remember that it will only be able to get wishlists that are already public, as it’s no authentication going on, just good old web scraping.

It’s not very fancy, and will only output the values it finds. If I find the time (and inspiration) I might be able to convert some of the values into types that are more logical so that it will be easier to sort/filter etc. But hopefully you might find it helpful as is.


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
}))
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s