如何使用PowerShell获取HTML注释
如果我有HTML注释:如何使用PowerShell获取HTML注释,html,powershell,comments,Html,Powershell,Comments,如果我有HTML注释: <html> <body> <!-- some comment1 --> </body> </html> <!-- some comment2 --> 但是,$webrequest.ParsedHtml.body.innerHTML是一个字符串,我不知道如何获取评论或只是列出网站上的所有评论 我不确定是否会得到[if IE]类型的注释,因为它们是特殊的符号(即
<html>
<body>
<!-- some comment1 -->
</body>
</html>
<!-- some comment2 -->
但是,
$webrequest.ParsedHtml.body.innerHTML
是一个字符串,我不知道如何获取评论或只是列出网站上的所有评论 我不确定是否会得到[if IE]
类型的注释,因为它们是特殊的符号(即,不仅仅是注释)
但是,要获取其他标记名,您可以在标记名上进行筛选
$url = "https://www.w3schools.com/tags/tag_comment.asp"
$webrequest = Invoke-WebRequest -Uri $url
$webrequest.AllElements | Where-Object tagName -eq "!"
结果:
innerHTML :
innerText :
outerHTML :
outerText :
tagName : !
innerHTML : <!-- MainLeaderboard-->
innerText :
outerHTML : <!-- MainLeaderboard-->
outerText :
tagName : !
innerHTML : <!-- BottomMediumRectangle -->
innerText :
outerHTML : <!-- BottomMediumRectangle -->
outerText :
tagName : !
innerHTML : <!-- RightBottomMediumRectangle -->
innerText :
outerHTML : <!-- RightBottomMediumRectangle -->
outerText :
tagName : !
innerHTML:
内部文本:
外层TML:
外部文本:
标记名:!
innerHTML:
内部文本:
外层TML:
外部文本:
标记名:!
innerHTML:
内部文本:
外层TML:
外部文本:
标记名:!
innerHTML:
内部文本:
外层TML:
外部文本:
标记名:!
@mplungjan$webrequest.ParsedHtml.body.innerHTML.Split(“完成了任务,很好。我稍后会将其标记为答案。
innerHTML :
innerText :
outerHTML :
outerText :
tagName : !
innerHTML : <!-- MainLeaderboard-->
innerText :
outerHTML : <!-- MainLeaderboard-->
outerText :
tagName : !
innerHTML : <!-- BottomMediumRectangle -->
innerText :
outerHTML : <!-- BottomMediumRectangle -->
outerText :
tagName : !
innerHTML : <!-- RightBottomMediumRectangle -->
innerText :
outerHTML : <!-- RightBottomMediumRectangle -->
outerText :
tagName : !