【发布时间】:2012-10-02 13:16:06
【问题描述】:
从远程网络服务器下载文件的最佳途径是什么?我想使用 .htaccess 拒绝所有下载,除非通过了特定的用户代理。这必须通过 cURL 完成还是 WGET 也可以这样做?
【问题讨论】:
-
没关系 wget 使用 libcurl...
-
这不是很安全。任何人都可以更改他们的用户代理
从远程网络服务器下载文件的最佳途径是什么?我想使用 .htaccess 拒绝所有下载,除非通过了特定的用户代理。这必须通过 cURL 完成还是 WGET 也可以这样做?
【问题讨论】:
另外,记录在案,来自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.
【讨论】:
http://www.gnu.org/software/wget/manual/wget.html
‘-U 代理字符串’ '--user-agent=代理字符串' 标识为 http 服务器的代理字符串。 http 协议允许客户端使用 User-Agent 标头字段来标识自己。这可以区分 www 软件,通常用于统计目的或跟踪协议违规。 Wget 通常标识为“Wget/version”,version 是 Wget 的当前版本号。
但是,众所周知,某些网站会根据用户代理提供的信息实施定制输出的政策。虽然这在理论上并不是一个坏主意,但它已被服务器滥用,拒绝向(历史上)Netscape 或更常见的 Microsoft Internet Explorer 以外的客户端提供信息。此选项允许您更改 Wget 发出的 User-Agent 行。不鼓励使用此选项,除非您真的知道自己在做什么。
用'--user-agent=""'指定空用户代理指示Wget不要在http请求中发送User-Agent标头。
【讨论】: