问题
How do I get the output file to contain the images on the webpage and not just the links to the images?
PS C:\temp> Invoke-WebRequest http://mitpress.mit.edu/sites/default/files/titles/content/sicm/book-Z-H-51.html -OutFile C:\temp\51.html
回答1:
You need to explore the page a bit to figure out some of details. Here's a complete script which I've tested successfully.
Invoke-WebRequest http://mitpress.mit.edu/sites/default/files/titles/content/sicm/book-Z-H-51.html |
select -expand images |
select -expand src |
foreach { start-bitstransfer $("http://mitpress.mit.edu/sites/default/files/titles/content/sicm/{0}" -f $_) C:\Users\Public\Downloads}
来源:https://stackoverflow.com/questions/14054030/invoke-webrequest-to-get-complete-web-page-with-images