Wallpaper Downloader

0
[featured_image]
Download
Download is available until [expire_date]
  • Version
  • Download 341
  • File Size 0.93 KB
  • File Count 1
  • Create Date March 6, 2018
  • Last Updated March 6, 2018

Wallpaper Downloader

Source code:

function Download-Wallpaper
{
   param
   (
       [string]
       [Parameter(Mandatory)]
       $Folder,
 
       [Parameter(ValueFromPipeline)]
       [Int]
       $Page=1
   )
   
   begin
   {
       $url = "http://wallpaperswide.com/page/$Page"
       $targetExists = Test-Path  -Path $Folder
       if (!$targetExists) { $null = New-Item -Path $Folder -ItemType Directory }
   }
   process
   {
       $web = Invoke-WebRequest -Uri $url -UseBasicParsing
 
       $web.Images.src | 
       ForEach-Object {
   
           $filename = $_.Split('/' )[-1].Replace('t1.jpg','wallpaper-3840x2160.jpg')
           $source = "http://wallpaperswide.com/download/$filename"
   
           $TargetPath = Join-Path -Path $folder -ChildPath $filename
 
           Invoke-WebRequest -Uri $source -OutFile $TargetPath
       }
   }
   end
   {
       explorer $Folder
   }
}
Download-Wallpaper -Folder d:	empwallpaper