Wget and the user agent option

Ubuntu 15.10 GNOME Terminal

Wget is a command-line utility for downloading files.

The official description on its man page on my Linux distribution says that it is “free utility for non-interactive download of files from the Web”, and that it “supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.”

It especially comes in handy when I need to download an image from another Web resource. I’ve never had any problem using it until just today when I got a 403 Forbidden error message. The edited output is shown in this code block:

wget http://www.example-site.com/image.png
--2015-01-12 19:23:14--  http://www.example-site.com/image.png

Resolving www.example-site.com (www.example-site.com)... 555.111.111.111, 555.111.113.112
Connecting to www.example-site.com (www.example-site.com)|555.111.111.111|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2015-01-12 19:23:14 ERROR 403: Forbidden.

Years ago I read somewhere that that usually indicates an Apache server that has been configured via .htaccess to deny file downloads or something of that nature. Since the image file was something I really needed for an article, I decided to poke around the documentation and search the Internet for clues. That effort drew my attention to one of the tools options – the –user-agent or -U option.

Related Post:  Finalterm now has tabs, horizontal and vertical split screens

Here’s what the man page has to say about it:

The HTTP protocol allows the clients to identify themselves using a “User-Agent” header field. This enables distinguishing the WWW software, usually for statistical purposes or for tracing of protocol violations. Wget normally identifies as Wget/version, version being the current version number of Wget.

However, some sites have been known to impose the policy of tailoring the output according to the “User-Agent”-supplied information. While this is not such a bad idea in theory, it has been abused by servers denying information to clients other than (historically) Netscape or, more frequently, Microsoft Internet Explorer. This option allows you to change the “User-Agent” line issued by Wget. Use of this option is discouraged, unless you really know what you are doing.

Specifying empty user agent with –user-agent=”” instructs Wget not to send the “User-Agent” header in HTTP requests.

With that, I decided to retry the download by specifying an empty user agent as shown in this code block:

wget http://www.example-site.com/image.png
--2015-01-12 19:23:14--  http://www.example-site.com/image.png

Resolving www.example-site.com (www.example-site.com)... 555.111.111.111, 555.111.113.112
Connecting to www.example-site.com (www.example-site.com)|555.111.111.111|:80... connected.

HTTP request sent, awaiting response... 200 OK
Length: 39946 (39K) [image/png]
Saving to: ‘image.png’

image.png         100%[=========================>]  39.01K  --.-KB/s   in 0.07s  

2015-01-12 19:37:58 (567 KB/s) - ‘image.png’ saved [39946/39946]

That was all it took. There might be other situations where the –user-agent or -U option likely fail, but in this specific case, that was what the doctor ordered.

Related Post:  The K Desktop Environment is 15

Share:

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn

Hola! Did you notice that LinuxBSDos.com no longer run network ads?  Yep, no more ads from the usual suspects that track and annoy you across the Internet. But since I still need to pay to keep the site running, feel free to make a small donation by PayPal or your favorite cryptocurrency.

  • Bitcoin
  • Ethereum
  • Xrp
  • Bitcoin cash
  • Bitcoin sv
  • Litecoin
  • Binance coin
  • Cardano
  • Ethereum classic
Scan to Donate Bitcoin to bc1qzvlte2m224zkayhdc7fdfjkp2rsgt0l5a496ua

Donate Bitcoin to this address

Scan the QR code or copy the address below into your wallet to send some Bitcoin

Scan to Donate Ethereum to 0x0F4362DFF77F3Ba0Dc637F5f3Eba35D09a2fA60C

Donate Ethereum to this address

Scan the QR code or copy the address below into your wallet to send some Ethereum

Scan to Donate Xrp to r4ggjvL36njsMCYTkJ3S7cTHscPsMsSGQv

Donate Xrp to this address

Scan the QR code or copy the address below into your wallet to send some Xrp

Scan to Donate Bitcoin cash to qrs0dedzp9t55af3nfwypydghp29r0xguy9s20fz2k

Donate Bitcoin cash to this address

Scan the QR code or copy the address below into your wallet to send some Bitcoin cash

Scan to Donate Bitcoin sv to 15K9TLyVDBtLuG9cYvXCX9SSkq9C9oUKHK

Donate Bitcoin sv to this address

Scan the QR code or copy the address below into your wallet to send some Bitcoin sv

Scan to Donate Litecoin to LetJ9QQMb7u2LMZ9Tu6rtHwcBcQFW98fbG

Donate Litecoin to this address

Scan the QR code or copy the address below into your wallet to send some Litecoin

Scan to Donate Binance coin to bnb1ga8trq08ssqepd90v6225nzfgy448pu5pw8gxp

Donate Binance coin to this address

Scan the QR code or copy the address below into your wallet to send some Binance coin

Scan to Donate Cardano to addr1qx2354yw49etstfljpdhwja3ajjlt487lg95vu9ngy2q6vu4rf2ga2tjhqknlyzmwa9mrm997h20a7stgectxsg5p5esq5l7d9

Donate Cardano to this address

Scan the QR code or copy the address below into your wallet to send some Cardano

Scan to Donate Ethereum classic to 0xcD6CC972a2297FcafACDcfE042C55C69516a9264

Donate Ethereum classic to this address

Scan the QR code or copy the address below into your wallet to send some Ethereum classic

Subscribe for updates. Trust me, no spam!

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.

Upcoming events

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest

On social media
Via my newsletter

Partner links

1. Attend Algorithm Conference, a top AI and ML event for 2021.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.
Hacking, pentesting distributions

Linux Distributions for Hacking

Experts use these Linux distributions for hacking, digital forensics, and pentesting.

Categories
Archives

The authors of these books are confirmed to speak during

Algorithm Conference

T-minus AI

Author was the first chairperson of AI for the U.S. Air Force.

The case for killer robots

Author is the Director of the Center for Natural and Artificial Intelligence.

Why greatness cannot be planned

Author works on AI safety as a Senior Research Scientist at Uber AI Labs.