1. 程式人生 > >linux下的curl命令

linux下的curl命令

1,抓取頁面內容到一個檔案中
[[email protected] ~]# curl -o home.html  http://www.sina.com.cn 
2,用-O(大寫的),後面的url要具體到某個檔案,不然抓不下來。我們還可以用正則來抓取東西 
[[email protected] ~]# curl -O http://www.it415.com/czxt/linux/25002_3.html 
3,模擬表單資訊,模擬登入,儲存cookie資訊 
[[email protected] ~]# curl -c ./cookie_c.txt -F log=aaaa -F pwd=****** 
http://blog.51yip.com/wp-login.php 

4,模擬表單資訊,模擬登入,儲存頭資訊 
[[email protected] ~]# curl -D ./cookie_D.txt -F log=aaaa -F pwd=****** http://blog.51yip.com/wp-login.php 
-c(小寫)產生的cookie和-D裡面的cookie是不一樣的。
5,使用cookie檔案 
[[email protected] ~]# curl -b ./cookie_c.txt  http://blog.51yip.com/wp-admin 
6,斷點續傳,-C(大寫的)
[[email protected]
~]#
 curl -C -O http://www.sina.com.cn 
7,傳送資料,最好用登入頁面測試,因為你傳值過去後,curl回抓資料,你可以看到你傳值有沒有成功 
[[email protected] ~]# curl -d log=aaaa  http://blog.51yip.com/wp-login.php 
8,顯示抓取錯誤 
[[email protected] ~]# curl -f http://www.sina.com.cn/asdf 
curl: (22) The requested URL returned error: 404
[[email protected]
~]#
 curl http://www.sina.com.cn/asdf 
<HTML><HEAD><TITLE>404,not found</TITLE>
。。。。。。。。。。。。
9,偽造來源地址,有的網站會判斷,請求來源地址 
[[email protected] ~]# curl -e http://localhost http://www.sina.com.cn 
10,當我們經常用curl去搞人家東西的時候,人家會把你的IP給遮蔽掉的,這個時候,我們可以用代理 
[[email protected] ~]# curl -x 10.10.90.83:80 -o home.html http://www.sina.com.cn 
11,比較大的東西,我們可以分段下載
[[email protected] ~]# curl -r 0-100 -o img.part1 http://i2.f.itc.cn/thumb/180/bj/6018/b_60178154.jpg 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   101  100   101    0     0   1926      0 --:--:-- --:--:-- --:--:--     0
[[email protected] ~]# curl -r 100-200 -o img.part2 http://i2.f.itc.cn/thumb/180/bj/6018/b_60178154.jpg 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   101  100   101    0     0   3498      0 --:--:-- --:--:-- --:--:--   98k
[[email protected] ~]# curl -r 200- -o img.part3 http://i2.f.itc.cn/thumb/180/bj/6018/b_60178154.jpg     
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13515  100 13515    0     0   154k      0 --:--:-- --:--:-- --:--:--  280k
[[email protected] ~]# ll |grep img.part
-rw-r--r-- 1 root root   101 Jan 24 10:59 img.part1
-rw-r--r-- 1 root root   101 Jan 24 11:00 img.part2
-rw-r--r-- 1 root root 13515 Jan 24 11:00 img.part3
用的時候,把他們cat一下就OK了,cat img.part* >img.jpg
12,不顯示下載進度資訊
[[email protected] ~]# curl -s -o aaa.jpg  
13,顯示下載進度條 
[[email protected] ~]# curl -# -O  http://www.it415.com/czxt/linux/25002_3.html 
######################################################################## 100.0%
14,通過ftp下載檔案 
[[email protected] ~]# curl -u 使用者名稱:密碼 -O http://blog.51yip.com/demo/curtain/bbstudy_files/style.css 
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
101  1934  101  1934    0     0   3184      0 --:--:-- --:--:-- --:--:--  7136
或者用下面的方式
[[email protected] ~]# curl -O ftp://xukai:[email protected]:21/www/focus/enhouse/index.php 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 87518  100 87518    0     0  2312k      0 --:--:-- --:--:-- --:--:-- 11.5M
15,通過ftp上傳 
[[email protected] ~]# curl -T xukai.php ftp://xukai:[email protected]:21/www/focus/enhouse/         
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 87518    0     0  100 87518      0  2040k --:--:-- --:--:-- --:--:-- 8901k

相關推薦

Linuxcurl命令的使用

1.curl      簡單來說,curl是一個用url方式,來和伺服器進行檔案傳輸和下載的工具。它不僅僅支援Http協議,還支援了其他的眾多的協議,例如DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDA

Linux常用命令之sed學習總結

linux sed sed命令 正則表達式 sed總結 Sed功能說明:Sed是linux下一個強大的文本文件處理工具,通過對文件增加、刪除、查找、查詢操作,配合正則表達式以實現工作中的各種需求。同時也是一名運維人員必須掌握的核心技能。---------------------------

linuxcat命令詳解

forever ron localhost root sta testing 幫助 查看 一點 1、cat 顯示文件連接文件內容的工具; cat 是一個文本文件查看和連接工具。查看一個文件的內容,用cat比較簡單,就是cat 後面直接接文件名。 比如: de>[[

linuxalias命令具體解釋

margin san 登錄 white gre con 變量 每次 ext linux下alias命令具體解釋 用途說明 設置命令的別名。在linux系統中假設命令太長又不符合用戶的習慣,那麽我們能夠為它指定一個別名。盡管能夠為命令建立“鏈接” 解決長文件名

linuxyum命令出現Loaded plugins: fastestmirror

tle enable yum test enabled net post sdn http linux下yum命令出現Loaded plugins: fastestmirror yum install的時候提示:Loaded plugins: fastestmirror

linuxwget命令,支持斷點續傳,ftp、http、https等協議

strong 工作 等待 命名 wget命令 source cmd itl 操作 轉載的地址:http:[email protected]/* *//blog/static/32097310201171833420905/ 今天操作遠端機器的時候發現少一個安裝

LinuxDiff命令

普通 命令 圖形化 標準輸入 們的 sina 工具 文件 內容 一般正常比較兩個文件用vimdiff,算是直接進入vim界面,如果比較兩個文件夾下面的文件,可以用diff,註意,這裏只會比較文件夾下面的同名文件,他會列出不一樣的點. 參考Linux下Diff命令使用方法 d

Linux基礎命令(一)

linux find 實戰操作 每天積累知識就會有成長,只要付出在不久的將來一定會有收獲,可能回來的晚點,但是一定要貴在堅持,今天第一次發博客,如不出意外情況我每天都會發的,這個是我總結的find命令的一些實戰,希望我總結的知識點在今後會對大家有幫助。find -name "*a" #以a

Linuxfind命令的使用

find為什麽要使用find命令? Linux系統中有著成千上萬的文件,如果你想要找到自己想要的文件,一款查找軟件是必不可少的,而locate是根據其生成的數據庫進行查找,雖然速度會略快,但非實時查找,有些新的文件或目錄是匹配不到的,而且locate是模糊匹配,而find命令為實時查找,且為精確匹配,如

linuxvim命令詳解

但是 左移 功能 命令 file lips 查找替換 括號匹配 所想 高級一些的編輯器,都會包含宏功能,vim當然不能缺少了,在vim中使用宏是非常方便的::qx 開始記錄宏,並將結果存入寄存器xq 退出記錄模式@x 播放記錄在x寄存器中的宏命令稍微

【轉載】Linuxchkconfig命令詳解

name scrip 再次 http 缺省 重新 禁止 level pool chkconfig命令主要用來更新(啟動或停止)和查詢系統服務的運行級信息。謹記chkconfig不是立即自動禁止或激活一個服務,它只是簡單的改變了符號連接。 使用語法:chkconfig [--

linux 命令

print code col top clas class span log lin 1 find / -name 文件名 -type d 查找目錄 2 3 find / -name 文件名 -print 查找文件名 1 service 程序

linuxfile命令使用技巧

file命令使用1. windows以不同的擴展名來區分不同的文件,例如:.exe .png等2. linux下對擴展名沒有明確的要求有時就會遇到各種坑,當我們不知道是一個壓縮文件,用一些命令查看的時候,會出現各種亂碼[[email protected] ~]# cat text |he

linuxiptables命令的應用與詳解

iptables 一、iptables的規則表和鏈。 表(tables)提供特定的功能,iptables內置了4個表,即filter表、nat表、mangle表和raw表,分別用於實現包過濾,網絡地址轉換、包重構(修改)和數據跟蹤處理。 鏈(chains)是數據包傳播的路徑,每一條鏈其實就是眾多規則中的

Linux命令之clear和reset

linux clear reset 清除屏幕 1) clear : 刷新屏幕 保留歷史命令記錄 說明:此命令本質上是讓終端向後翻一頁 當向上滾動鼠標時,還是可以看到之前的命令操作記錄 2) reset : 重新初始化屏幕,清除歷史命令操作記錄本文出自 “梵高說我腦子有病” 博客,謝絕

Linux常用命令總結

命令註:本文檔只記錄最常用的命令以及命令下的參數,更多的命令請參考linux文檔或使用命令help、man、info 進行對應查詢常用文件目錄操作指令ls 參數 文件 顯示文件或目錄(文件為空時,代表顯示當前目錄) -l 列出文件詳細信息l(list)

linuxexpect命令實現批量ssh免密

輸入 left 防止 輸出 one 時間 line jdb eof 有時候我們需要批量發送ssh命令給服務器,但是有可能有些服務器是新加入的,還沒有配置ssh免密,這個時候就會提示我們輸入yes/no 或者password等,expect腳本命令就是用於在提示這些的時候

linuxyum命令出現Loaded plugins: fastestmirror Determining fastest mirrors

找到 plugin mir con test lin fast load min 今天yum install的時候出問題了,找了半天才找到一個可行的解決辦法 fastestmirror是yum的一個加速插件,這裏是插件提示信息是插件不能用了。 不能用就先別用唄,禁用掉,先y

linuxhistory命令顯示歷史指令記錄的使用方法

語法 tex 系統 linux下 命令 過程 相關 不堪 中間 linux下history命令顯示歷史指令記錄的使用方法 History命令主要用於顯示歷史指令記錄內容, 下達歷史紀錄中的指令 。1>History命令語法: [test@li

Linuxrar 命令壓縮和解壓詳解

保持 介紹 詳細 註意 壓縮 rar 縮進 command 解壓縮 例1:添加文件或目錄到壓縮檔案中,使用a命令。例如把文件files1添加到abc.rar中,使用a或m命令,a命令把file1文件添加到abc.rar檔案中保持原有的file1文件不變,m命令移動file1