我在 Unix/Linux 上做过一些编程,但最近 PowerShell 在我的工作中更有用。然而,缺乏使grep
我发疯。有人可以解释这种现象吗?
我试图让今天 IOTA 的价值恢复到我可以的价值Write-Output
。
$webpage = Invoke-WebRequest -Uri https://coinmarketcap.com/currencies/iota/
$filtered = $webpage.ParsedHtml.body.innerText
这为我提供了我需要的所有信息,但它需要更多过滤。
$filtered | Select-String "IOTA"
这给了我所有的信息$filtered
,不知何故它无法选择那个字符串。但是,如果我这样做,它会起作用:
$filtered > filter.txt
Get-Content filter.txt | Select-String "IOTA"
我一直在尝试在网上搜索答案,我发现最接近的是它可能$filtered
作为对象处理,而不是字符串。如果我检查,它说它是一个字符串。
PS> $filtered.GetType() IsPublic IsSerial 名称 BaseType -------- -------- ---- -------- True True 字符串 System.Object
这不是我第一次经历Select-String
失败。我究竟做错了什么?