Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PowerShell获取HTML注释_Html_Powershell_Comments - Fatal编程技术网

如何使用PowerShell获取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注释:

<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   : !