Leo Torres
asked on
powershell parse
The code below works to a certain extent. I need to refine it a bit.
2 things I need.
1. I need to only return scores for 20110114
2. I need this make this into a function where I can call it from the command line and pass it a date. In this format
20141126 is an example.
2 things I need.
1. I need to only return scores for 20110114
2. I need this make this into a function where I can call it from the command line and pass it a date. In this format
20141126 is an example.
CLS
Add-Type -path C:\pstemp\HtmlAgilityPack\Net40\htmlagilitypack.dll
$Website = "http://espn.go.com/nba/schedule?date=20110114"
$wc = New-Object System.Net.WebClient;
$doc = New-Object HtmlAgilityPack.HtmlDocument
$doc.LoadHtml($wc.DownloadString($Website))
Foreach ($game in $doc.DocumentNode.SelectNodes('.//table["tablehead"]'))
{
$rows = $game.SelectNodes('tr')
$Day = $rows[0].InnerText
Foreach ($row in $rows)
{
$col = $row
IF ($col.Attributes["class"].value -ne "colhead")
{
$str2 = $col.ChildNodes[0].InnerText
Write-host $str2
}
}
}
ASKER
Cool works!!!
Can you elaborate on this logic here please
IF ("stathead", "colhead" -notcontains $col.Attributes["class"].v alue)
Can you elaborate on this logic here please
IF ("stathead", "colhead" -notcontains $col.Attributes["class"].v
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great. I will try to insert this into a database.
I will give it a stab. I will post if I get stuck thanks
I will give it a stab. I will post if I get stuck thanks
ASKER
Thanks
Open in new window
After importing that into your PS console by using something alongOpen in new window
you can call it withOpen in new window