Skip to content

Instantly share code, notes, and snippets.

@milnak
Created July 17, 2024 03:25
Show Gist options
  • Save milnak/7d516082eb1cacdc59bbde585bbb908b to your computer and use it in GitHub Desktop.
Save milnak/7d516082eb1cacdc59bbde585bbb908b to your computer and use it in GitHub Desktop.
Download binaries from a web page using wget
<#
.SYNOPSIS
Download binaries by extension from a web page.
#>
function Get-WebPageBinaries {
[CmdletBinding()]
param(
# Uri of page to download from.
[Parameter(Mandatory)] [uri]$Uri,
# Extensions to download
[string[]]$Extensions = @('zip','pdf','mp3','mid'),
# Maximum recursion depth, 0=infinite
[int]$Depth = 1
)
$accept = ($Extensions | ForEach-Object { ".$_" }) -join ','
wget.exe `
--no-parent `
--recursive `
--level=$Depth `
--continue `
--timestamping `
--execute robots=off `
--accept=$accept `
--user-agent='Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/52.0.2725.0 Mobile/13B143 Safari/601.1.46' `
$Uri
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment