Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active July 15, 2024 22:31
Show Gist options
  • Save dfinke/4467657 to your computer and use it in GitHub Desktop.
Save dfinke/4467657 to your computer and use it in GitHub Desktop.
Uses PowerShell v3 to find the free chapters of "PowerShell in Depth" and downloads the PDF
$url="http://www.manning.com/jones2/"
(Invoke-WebRequest $url).links | where onclick -match 'free' | foreach {
[PSCustomObject] @{
innerHTML = $_.innerHTML
FullHref = $url+$_.href
href = $_.href
url = $url
}
} | ForEach {
$outFile = "c:\temp\$($_.href)"
"Downloading $($_.InnerHtml) -> $($outFile)"
Invoke-WebRequest $_.FullHref -OutFile $outFile
}
@sunnyc7
Copy link

sunnyc7 commented Jan 7, 2013

Small Hack, but I am not able to save the file with 4567.ps1 or advanced event.ps1

download all scripting games code by Rohn Edwards

$url="http://2012sg.poshcode.org/Scripts/By/862"

(Invoke-WebRequest $url).links | where{$.innerHTML -eq "Download"} | ForEach {
$outFile = "c:\temp$($
.outerText)"
#"Downloading $($_.InnerHtml) -> $($outFile)"
$callstring = "http://2012sg.poshcode.org"+$_.href
$callstring
Invoke-WebRequest $callstring -OutFile $outFile
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment