Which is going to be the best route to download a file from a remote webserver? I want to use .htaccess to deny all downloads unless a specific useragent is passed. Would this have to be done via cURL or can WGET do this too?
-
1Nevermind wget uses libcurl... – Oct 11 '12 at 19:21
-
That is not very secure. Anyone can just change their useragent, too – BeniBela Apr 26 '14 at 19:33
2 Answers
http://www.gnu.org/software/wget/manual/wget.html
‘-U agent-string’ ‘--user-agent=agent-string’ Identify as agent-string to the http server. 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.
Also, for the record, from man curl(1)
:
-A, --user-agent <agent string>
(HTTP) Specify the User-Agent string to send to the HTTP server.
Some badly done CGIs fail if this field isn't set to
"Mozilla/4.0". To encode blanks in the string, surround the
string with single quote marks. This can also be set with the
-H, --header option of course.
If this option is used several times, the last one will be used.

- 9,423
- 6
- 62
- 70