Leo Torres
asked on
Powershell, Split String
Again I cant seem to align my columns here games are fine but time and date are skewed. What is my issue this same as last time but I cant seem to put a finger on it.
My games has Dates and My date column just has a constant. when it should be a date.
My games has Dates and My date column just has a constant. when it should be a date.
CLS
# HAP available at http://htmlagilitypack.codeplex.com/
# (originally http://www.nuget.org/packages/HtmlAgilityPack)
Add-Type -path C:\pstemp\HtmlAgilityPack\Net40\htmlagilitypack.dll
#Add-Type -path C:\pstemp\HtmlAgilityPack\Net20\htmlagilitypack.dll
$Website = 'http://espn.go.com/nfl/schedule'
$wc = New-Object System.Net.WebClient;
$doc = New-Object HtmlAgilityPack.HtmlDocument
$doc.LoadHtml($wc.DownloadString($Website))
$games = @()
$Allgames = @()
foreach ($day in $doc.DocumentNode.SelectNodes('//table["tablehead"]'))
{
$rows = $day.SelectNodes('tr')
$Week = $rows[0].InnerText -replace "back to top »", ""<# [DateTime] #>
foreach ($row in $rows[2..$rows.Count])
{
$col = $row.Element('td');
if ($col.Attributes["class"].value -eq "colhead")
{ # a day
$day = $col.ChildNodes[1].InnerText
}
$teams = $col.InnerText
$col = $col.NextSibling;
$time = ($col.ChildNodes[0,2] | Select -ExpandProperty InnerText) -join " at "
$games += New-Object PsObject -Property @{Week = $week;date = $day; time = $time; Teams = $teams}
}
}
$Allgames += $games
$Allgames | select Week,Date,time,@{Name='Games';Expression={[string]$_.Teams}} | Format-Table -AutoSize
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for being patient!
ASKER
I tried to put the time outside of loop. An failed again. but thank I need this before the 5th. Once the first game happens the page changes...
Thanks again!