Download wallpapers from InterfaceLift

The following code will automatically scrape the latest wallpapers from InterfaceLift. This code could be scheduled to run at startup and automatically update the target folder to be used as a wallpaper slideshow. A second script is to download to a static image file that will update as InterfaceLift releases a new image.

Shout out to InterfaceLift which have some of the most beautiful wallpapers out there.  If you use AdBlock be sure to support the site by excluding it and allowing the ads to download.

# Written by Ben Penney https://sysadminben.wordpress.com # Change this line to match the resolution of the image to download. It must be in the same string format used by InterfaceLift $Resolution = "1920x1200" # Folder where the images will download to $TargetPath = "$($env:USERPROFILE)\Pictures\InterfaceLift" # If folder InterfaceLift does not exist in the users Pictures folder it creates it If (!(Test-Path $TargetPath)) {New-Item -ItemType Directory $TargetPath} # The following string is used to match the urls of the preview images in the main page. These names are used in the full resolution images [regex]$regex = "(?<=\/wallpaper\/previews\/).*?(?=_672x420.jpg)" # This line downloads the web page and looks for the above string matches $regex.Matches((Invoke-WebRequest "https://interfacelift.com/wallpaper/downloads/date/any").Content) | foreach-object { # Generate the final image name from the matched strings above $FileName = "$($_)_$Resolution.jpg" # Check the image has not already been downloaded If (Test-Path "$TargetPath\$FileName") { # Skip if the file exists "'$FileName' exists. Skipping." } Else { # Download the file "Downloading file '$FileName'" Invoke-WebRequest "http://interfacelift.com/wallpaper/7yz4ma1/$FileName" -OutFile "$TargetPath\$FileName" } }

Second script that overwrites a single image file. Once the script is run for the first time point your wallpaper to the InterfaceLift.jpg file in your Pictures folder.

# Written by Ben Penney https://sysadminben.wordpress.com # Change this line to match the resolution of the image to download. It must be in the same string format used by InterfaceLift $Resolution = "1920x1200" # Folder where the images will download to $TargetPath = "$($env:USERPROFILE)\Pictures\InterfaceLift.jpg" # The following string is used to match the urls of the preview images in the main page. These names are used in the full resolution images [regex]$regex = "(?<=\/wallpaper\/previews\/).*?(?=_672x420.jpg)" # Grab the name of the latest image $LatestImage = (Invoke-WebRequest "https://interfacelift.com/wallpaper/downloads/date/any/index$int.html").Content)[0] # Generate the final filename of the full resolution image $FileName = "$($regex.Matches($LatestImage)_$Resolution.jpg" # Download the file "Downloading file '$FileName'" Invoke-WebRequest "http://interfacelift.com/wallpaper/7yz4ma1/$FileName" -OutFile "$TargetPath"

Advertisements