簡體   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