我在成长

wget 之http

上一篇 / 下一篇  2012-03-24 17:40:30 / 个人分类:个人日记

wget其实是一个有点儿小强大的工具,之前都是远程获取data使用,这次的需求是想在脚本运行的时候,可以动态的发送一个请求到服务,来记录脚本运行的情况,比如每次脚本是谁运行的,运行时间是多少等等,用于统计分析可以用的方法有很多,大部分用curl,我想让脚本越简单越好,能少写一行就少写一行,所以选择用wget

我们看下wget的http option有什么
HTTP options:
       --http-user=USER        set http user to USER.
       --http-password=PASS    set http password to PASS.
       --no-cache              disallow server-cached data.
  -E,  --html-extension        save HTML documents with `.html' extension.
       --ignore-length         ignore `Content-Length' header field.
       --header=STRING         insert STRING among the headers.
       --proxy-user=USER       set USER as proxy username.
       --proxy-password=PASS   set PASS as proxy password.
       --referer=URL           include `Referer: URL' header in HTTP request.
       --save-headers          save the HTTP headers to file.
  -U,  --user-agent=AGENT      identify as AGENT instead of Wget/VERSION.
       --no-http-keep-alive    disable HTTP keep-alive (persistent connections).
       --no-cookies            don't use cookies.
       --load-cookies FILE     load cookies from FILE before session.
       --save-cookies FILE     save cookies to FILE after session.
       --keep-session-cookies  load and save session (non-permanent) cookies.
       --post-data=STRING      use the POST method; send STRING as the data.
       --post-file=FILE        use the POST method; send contents of FILE.


很容易看懂吧,最有用的就是最后两个了,可以直接发送请求到服务器,如果你的服务比较变态,可以考虑上面的参数

给个例子
我想发送两个值到服务器
wget --post-data="user=weixiaoyeah&runtime=$runtime"  -q http://127.0.0.1:8888/log.php



TAG:

 

评分:0

我来说两句

日历

« 2024-04-17  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 48014
  • 日志数: 34
  • 图片数: 1
  • 书签数: 4
  • 建立时间: 2010-01-12
  • 更新时间: 2012-03-24

RSS订阅

Open Toolbar