Jan 062011
This is so incredibly easy. With only three simple lines of code, you can capture all the HTML content from a web page.
Are you ready?
Here goes:
$webclient = new-object system.net.WebClient $webpage = $webclient.DownloadData("http://www.google.com/#q=poshtips.com") $pagedata = [System.Text.Encoding]::ASCII.GetString($webpage) |
The contents of the specified web page will be contained in the $pagedata variable.
To save the page contents to a file, simply add one more line of code as follows:
$webclient = new-object system.net.WebClient $webpage = $webclient.DownloadData("http://www.google.com/#q=poshtips.com") $pagedata = [System.Text.Encoding]::ASCII.GetString($webpage) $pagedata | out-file "googlesearch.html" |
That’s all there is to it.