Saving a web page from IE using Powershell

半世苍凉 提交于 2019-12-19 09:13:31

问题


I use the automation interface of Internet Explorer from Powershell to open a web page in a supported format. I want to save this page back to disk in one of the formats supported by IE. Opening the page is easy:

$ie = New-Object -ComObject "InternetExplorer.Application"
$ie.Navigate("C:\MyFile.mht")

How do I save it back in another format?

I need a solution that does not prompt the user since the idea is to automate this in a script running through multiple files.


回答1:


You want to call ExecWB with the appropriate args:

$ie.ExecWB(4,0,$null,[ref]$null)

Explanation of the 4 params:

4 = OLECMDID_SAVEAS
0 = OLECMDEXECOPT_DODEFAULT (This can also be 2 = OLECMDEXECOPT_DONTPROMPTUSER to not prompt and just save)
$null = NULL (I think this can be a path to save to: separate folders with 2 slashes (\\))
[ref]$null = ref NULL :)


来源:https://stackoverflow.com/questions/872750/saving-a-web-page-from-ie-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!