【问题标题】:WGET or cURL to get file with protectionWGET 或 cURL 获取受保护的文件
【发布时间】:2012-10-02 13:16:06
【问题描述】:

从远程网络服务器下载文件的最佳途径是什么?我想使用 .htaccess 拒绝所有下载,除非通过了特定的用户代理。这必须通过 cURL 完成还是 WGET 也可以这样做?

【问题讨论】:

  • 没关系 wget 使用 libcurl...
  • 这不是很安全。任何人都可以更改他们的用户代理

标签: linux bash curl wget


【解决方案1】:

另外,记录在案,来自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.

【讨论】:

    【解决方案2】:

    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标头。

    【讨论】:

      猜你喜欢
      • 2020-10-19
      • 2012-05-21
      • 1970-01-01
      • 2014-07-08
      • 2019-02-04
      • 1970-01-01
      • 2019-01-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多