Battle Faction Puzzle 3

This topic contains 2 replies, has 3 voices, and was last updated by  Darwin 3 weeks ago.

  • Author
  • #92327

    Axel Bøg Andersen

    Here is a solution that works in 5.1 and 6.0

  • #92341


    I like what Axel is doing. In Puzzle 2 he returned all parameters and then filtered with format file.
    Why we need format file for 9-11 elements? Look on gps (get-process): tabular output 7 properties, but you can get all (~70) if you want. It the battle we want the best needed, but might want more. And without changing the script code.

    "" | %{$feedsResult=(irm $_ | select @{n='Title';e={$_.title}},@{n='Publication Date';e={$_.pubDate}},@{n='Author';e={$_.creator}},@{n='Link';e={$_.Link}}); $feedsResult | ft -a; $titleToOpen=read-host "Copy/Paste Title you want to see"; $textOrBrowser=read-host "Open in [B]rowser or dump to [C]onsole?"; if ($textOrBrowser -eq "B") {start-process ($feedsResult | ? Title -match "$titleToOpen").link} elseif ($textOrBrowser -eq "C") {if ($PSVersionTable.PSEdition -ne "core") {(iwr ($feedsResult | ? Title -match "$titleToOpen").link).allelements | ? class -match entry-content | select -ExpandProperty outerText | fl} else {"`niwr in PSCore ...`n"}} else {write-host -f red "`nWrong choice - exiting...`n"}}

    iwr won't work in 6.0, like in 5.1 because it doesn't support ie's stuff.

    And i killed the puppy, sorry :(. I'm doing this a lot...

  • #92345

    Function Get-FeedArticle {
      param (
      $Feed = [xml](Invoke-WebRequest -Uri "$FeedURI" -usebasicparsing)
      $Items = $ | Sort-Object pubDate -Descending | ForEach-Object {$i=1} {Add-Member -InputObject $_ -MemberType NoteProperty -Name Index -Value ($i++) -PassThru}
      $Items | Sort-Object Index | select index, @{Name='Date';Expression={([datetime]$_.pubDate).tostring('MM/dd/yyyy')}},title,@{Name="Author";Expression={$_.creator.InnerText}},link | ft
      $Selected = Read-Host -Prompt "Type the article index you wish to display, add 'c' after the number to view content here in the console"
      If ($Selected -ilike '*c')
        $selected = $selected.trimend('c')
        $Body = @{ strURL = "$($Items | where {$_.index -eq $Selected} | select -expand link)" }
        $results = invoke-webrequest -uri '' -Body $Body -Method 'Get'
        $results.parsedhtml.getelementbyid('content').outertext | more
      else {
        Start-Process "$($Items | where {$_.index -eq $Selected } | select -expand link)"

You must be logged in to reply to this topic.