Powershell: Download or Save source code for whole ie page

前端 未结 2 1288
长情又很酷
长情又很酷 2020-12-21 08:05

I have this PS script it logins to a site and then it navigate\'s to another page.

I want to save whole source for that page. but for some reason. some parts of sour

2条回答
  •  渐次进展
    2020-12-21 08:35

    After you navigate, check for the Ready State again instead of using a sleep. The same code that you had will work.

    It appears after running the code, the sleep may not be long enough if the site is slow to load.

    while($ie.ReadyState -ne 4) {start-sleep -m 100}
    

    It also looks like there is another post regarding this innerHTML converts CDATA to comments It looks like some one created a function on that page where you can clean it up. It would be something like this once you have the function declared in your code

    htmlWithCDATASectionsToHtmlWithout($ie.Document.body.outerHTML) | Out-File -FilePath c:\sourcecode.txt
    

提交回复
热议问题