This evening I’m relaxing and having a play with downloading web files without the need for a web browser, writing my notes as I go.

POWERSHELL
Powershell allows for an webrequest to save (or outfile) the requested file to a local location. My early attempt at a PowerShell script to do this is:

#Two variables are needed

#The first variable is where the file is online

$onlinelocation = “webaddress/images/example.png”

#The seconds variable is where the file should be saved (downloaded) to

$downloadto = “C:\temp\example.png”

#Then invoke a webrequest and utilise outfile to save the files

Invoke-WebRequest $onlinelocation -OutFile $downloadto

The draw back is that the save to folder (in this case \temp\) has to exist otherwise PowerShell errors. I’ll look at this at another time so that PowerShell checks for the save location and creates it if it does not exist.

BASH

Bash has a command called wget which is great for downloading web files:

wget webaddress/example.html

wget also has arguments that can be used before the web address:

wget -p -k webaddress/example.html downloads the page, any images it contains and the CSS referenced by the page.

wget -r -l webaddress downloads the entire website.

 

One response to “Downloading Web Files Without A Browser”

  1. Downloading Multiple Files Via Wget (Linux) – Geek Tech Stuff Avatar

    […] I first started my website I discussed some of the options of using the command line / terminal to download content from the internet without using a web […]

    Like

Welcome to GeekTechStuff

my home away from home and where I will be sharing my adventures in the world of technology and all things geek.

The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.

Let’s connect