iNNOKENTIY21
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору PowerShell Код: # https://anglesharp.github.io/ using namespace AngleSharp using namespace AngleSharp.Html.Parser using namespace System.IO using namespace System.Text Add-Type -Path "$PSScriptRoot\AngleSharp.dll" $parser = New-Object -TypeName AngleSharp.Html.Parser.HtmlParser $file = "$PSScriptRoot\Программы.html" # сохранено из http://forum.ru-board.com/forum.cgi?forum=5 $encoding = [Encoding]::GetEncoding("windows-1251") $source = [File]::ReadAllText($file, $encoding) $document = $parser.ParseDocument($source) $tableSelector = "body > table:nth-child(13) > tbody" $table = $document.QuerySelector($tableSelector) $rows = $table.QuerySelectorAll("tr") $ruBoardActiveTopicTable = @() foreach ($row in $rows) { $line = [Row]::new() $A = 0 $null = [int]::TryParse($row.QuerySelector("td:nth-child(4)").TextContent, [ref] $A) $line.Title = $row.QuerySelector("td.poster > span > a").TextContent $line.Author = $row.QuerySelector("td:nth-child(3) > a").TextContent $line.Answers = $A $line.UpdatesDate = [Convert]::ToDateTime($row.QuerySelector("td:nth-child(5) div[id^=lst]").TextContent) $line.UpdatesMember = $row.QuerySelector("td:nth-child(5) > a").TextContent $ruBoardActiveTopicTable += $line } $ruBoardActiveTopicTable | Where-Object { ($_.Title) -and ($_.Title -NotMatch "Поиск по форуму") } | Format-Table -AutoSize #ForEach-Object { $_.ToString() } class Row { [string] $Title [string] $Author [int] $Answers [DateTime] $UpdatesDate [string] $UpdatesMember [string] ToString() { return "{0} - Updates: {1} by {2}" -f $this.Title, $this.UpdatesDate, $this.UpdatesMember } } |
|