linux shell 學習摘記(5)

onephone發表於2016-10-03

《linux shell 指令碼程式設計攻略 (第2版)》 第五章 ”一團亂麻?沒有這回事“ 筆記

主要命令:wget, lynx, curl, 圖片抓取指令碼, 網頁相簿生成指令碼

  • wget

    1. wget -t 5 www.codeshold.me, wget -t 0 www.codeshold.me 無限次嘗試, -O outfile.html, -o out.log
    2. 可限速 --limit-rate 20k, 可限制配額 --quota 100m-Q 100m
    3. 斷點續傳 wget -c www.codeshold.me
    4. 映象整個網站 wget --mirror --convert-links www.codeshold.me 或者 wget -r -N -k -l DEPTH URL,其中-k--convert-links指示wget將頁面的連結地址轉換為本地地址,-N使用檔案的檔案戳
    5. wget --user USERNAME --password PADDWD URL
    6. wget http://10.108.255.249/cgi-bin/do_login --post-data "username=$name&password={TEXT}$pass&drop=0&type=1&n=100"i -q
  • lynx

  • curl

    1. curl www.codeshold.me -o swf.html --progress, --silent 不顯示進度資訊
    2. 斷點續傳 curl URL/file -C offset, curl -C -URL(程式自己推斷出續傳的位置)
    3. 參照頁(refer)可標誌使用者從哪個頁面到達當前頁面的,呈現的頁面可能會不一樣 curl --referer www.google.com www.codeshold.me
    4. curl www.codeshold.me --cookie "user=wuzhimang;pass=mydream", 將cookie另存為一個檔案 curl www.baidu.com --cookie-jar cookie.file
    5. 使用使用者代理(user agent),某些網站需特定的瀏覽器支援支援(如IE)curl www.codeshold.me --user-agent "Mozilla/5.0" 使用者代理字串
    6. 新增頭部資訊curl -H "Host: www.codeshold.me" -H "Accept-language: en" www.codeshold.me
    7. 限定 --limit-rate 20k, --max-filesize bytes
    8. 認證 curl -u user:pass http://codeshold.me, curl -u user http://10.108.255.249/
    9. 新增頭部 -I--head
    10. 命令列訪問Gmail (不能用的)此處有指令碼
  • 圖片抓取器

  • 網頁相簿

  • POST請求 curl URL -d "XXX", wget URL --post-data "XXX" -O output.html 指令碼

相關文章