【发布时间】:2018-05-15 05:37:17
【问题描述】:
我有以下 link ,当我通过 Chrome 打开链接然后右键单击该页面然后选择“另存为”以将页面保存到 HTML 文件中 (c:\temp\cu2.html )
保存后,我可以用 HTML 编辑器(比如 VS2015)打开这个 cu2.html 文件,我可以看到 在文件中,有如下所示的标签
但是,如果我用 IE11(而不是 Chrome)打开链接,然后将同一页面保存为 HTML 文件,我根本找不到这个标签。实际上,从IE11保存的html文件和我用下面的PowerShell脚本可以提取的内容是一样的。
#Requires -version 4.0
$url = 'https://support.microsoft.com/en-us/help/4052574/cumulative-update-2-for-sql-server-2017';
$wr = Invoke-WebRequest $url;
$wr.RawContent.contains('<table') # returns false
$wr.RawContent | out-file -FilePath c:\temp\cu2_ps.html -Force; #same as the file saved from the webpage to html file in IE
所以我的问题是:
为什么在 Chrome 中保存的网页(作为 html 文件)与在 IE 中的不同?
如何使用 PowerShell(或 C#)将此类网页保存为 HTML 文件(与 Chrome 中保存的文件相同)?
提前感谢您的帮助。
【问题讨论】:
标签: html powershell google-chrome web