繁体   English   中英

WGET或cURL获取带有保护的文件

[英]WGET or cURL to get file with protection

从远程Web服务器下载文件的最佳途径是哪一条? 我想使用.htaccess拒绝所有下载,除非通过了特定的useragent。 这必须通过cURL完成还是WGET可以做到这一点?

http://www.gnu.org/software/wget/manual/wget.html

'-U agent-string''--user-agent = agent-string'标识为http服务器的代理字符串。 http协议允许客户端使用User-Agent标头字段标识自己。 这通常可以出于统计目的或用于跟踪协议违规而区分www软件。 Wget通常标识为“ Wget /版本”,版本是Wget的当前版本号。

但是,已知某些站点会根据用户代理提供的信息强加调整输出的策略。 尽管从理论上讲这并不是一个坏主意,但是服务器拒绝了向客户端发送信息,而不是(从历史上)Netscape,或者更常见的是Microsoft Internet Explorer。 此选项使您可以更改Wget发出的User-Agent行。 不鼓励使用此选项,除非您真的知道自己在做什么。

用'--user-agent =“”指定空的用户代理会指示Wget不要在http请求中发送User-Agent标头。

另外,出于记录目的,来自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.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM