gpt4 book ai didi

powershell - 使用 Powershell 仅查找今天发生的那些全局假期

转载 作者:行者123 更新时间:2023-12-04 01:47:49 25 4
gpt4 key购买 nike

我是使用 Powershell 的新手,我正在尝试使用下面的网站抓取一个网站以仅查找今天发生的那些全局假期。

https://eresearch.fidelity.com/eresearch/markets_sectors/global/holidayCalendar.jhtml

这是我到目前为止所得到的,任何帮助将不胜感激!

$a = Get-Date -UFormat "%m/%d/%y" #to get the date in mm/dd/yy format
$source = "https://eresearch.fidelity.com/eresearch/markets_sectors/global/holidayCalendar.jhtml"
$result = Invoke-WebRequest $source
$d = $result.AllElements | Where Class -eq "layout-calendar-content-column" | Select -ExpandProperty innerText

echo $d

理想情况下,它只会显示与变量 $a 中包含的日期相匹配的假期。

最佳答案

您的脚本即将完成。而不是你的 echo 语句,试试这个:

$d -split "`n" | ? { $_ -like "*$a*" }

更新:针对您的用例

($d | Out-String) -split "`n" | Where-Object { $_ -like "*$a*" }

关于powershell - 使用 Powershell 仅查找今天发生的那些全局假期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47210322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com