[PowerShell] / Get-HpProductInfo.ps1 Repository:
ViewVC logotype

View of /Get-HpProductInfo.ps1

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (download) (annotate)
Sat Aug 10 06:33:52 2013 UTC (10 years, 8 months ago) by ian
File size: 2048 byte(s)
Renamed get-hpPcInfo.ps1 to Get-HpProductInfo.ps1 and cleaned up experimental code;
þÿ#Set-StrictMode -Version Latest



$queryUrl = "http://partsurfer.hp.com/Search.aspx?searchText="

#SN CNU1051FZC should return 37 orderable parts (ending in -001)



$htClient = New-Object System.Net.Webclient

$htData = $htClient.DownloadString("$($queryUrl)CNU1051FZC")



#Clean HTML so it can be parsed into XML

$htData = -join $htData[$htData.IndexOf("<body")..($htData.LastIndexOf("</body>")+6)]

$htData = $htData -replace '(?sx:<script[\s\S]*?</script[\s\S]*?>)'

$htData = $htData -replace '(?sx:<noscript[\s\S]*?</noscript[\s\S]*?>)'

$htData = $htData -replace ' & ', " and "

$htData = $htData -replace "&\w{2,6};"

<#  will parse without these cleanup steps

$htData = $htdata -replace '^\s+$', " "

$htData = $htData -replace '<!Doctype[\s\S]*?>'

$htData = $htData -replace '(?sx:<option[\s\S]*?</option[\s\S]*?>)'

$htData = $htData -replace '(?sx:<!--[\s\S]*?-->)'

$htData = $htData -replace '(?sx:<input[\s\S]*?/>)'

end unused cleanup#>

$xmlData = [xml]$htData

#$xmlData.body.div.form.table[0].tr.td

Contact
ViewVC Help
Powered by ViewVC 1.0.4