Need to save the 'currently displayed' webpage as mhtml using VBScript/Powershell

I saw a lot of posts and solutions where powershell or vbscript can be used to save a webpage as mhtml file by providing the url of the page.

I run automation tests and during various stages need to save the webpage as it is currently displayed as an mhtml file. How can we do it using VBScript. If not VBScript, how can I do it using PowerShell?

April 21st, 2015 2:08pm

Hi,

Here's some starting information:

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

https://msdn.microsoft.com/en-us/library/aa752087%28v=vs.85%29.aspx

April 21st, 2015 2:37pm

I am not sure exactly how that works and will work on that. But one things that I am seeing that this would work with only IE. I wanted something that would work with Firefox and Chrome as well.

Free Windows Admin Tool Kit Click here and download it now
April 21st, 2015 3:02pm

Thanks. I am not looking to control the webpage using script.

I'm just looking to see if we can get the content of the webpage and save it in the mhtml format.

April 22nd, 2015 9:57am

You did ask for a solution that will work with Chrome and Firefox as well, that means automation of the web browser. Which Mike is referring to.

MHTML is not the same as HTML. It's a local version of whatever the web browser thinks will be required. That means that if the server sends different content for different browsers then that's what will happen. Some variation is routine, although now IE6 is dying off that's no longer as big an issue as it once was.

Which also means that you can't ensure it's a browser non-specific version that's being saved. If you want/need a copy of the HTML being rendered by Chrome/Firefox then you'll need to find a way to script/automate those browsers and I don't know of one either.


Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 10:46am

You did ask for a solution that will work with Chrome and Firefox as well, that means automation of the web browser. Which Mike is referring to.

MHTML is not the same as HTML. It's a local version of whatever the web browser thinks will be required. That means that if the server sends different content for different browsers then that's what will happen. Some variation is routine, although now IE6 is dying off that's no longer as big an issue as it once was.

Which also means that you can't ensure it's a browser non-specific version that's being saved. If you want/need a copy of the HTML being rendered by Chrome/Firefox then you'll need to find a way to script/automate those browsers and I don't know of one either.


April 22nd, 2015 2:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics