curl概述
- curl 是一個(gè)命令行實(shí)用程序,允許用戶
創(chuàng)建網(wǎng)絡(luò)請(qǐng)求
- curl 在
Windows
、Linux
和Mac
上皆可使用
post請(qǐng)求
一個(gè)簡(jiǎn)單的 POST 請(qǐng)求
-X
:指定與遠(yuǎn)程服務(wù)器通信時(shí)將使用哪種 HTTP 請(qǐng)求方法
curl -X POST http://example.com
POST 請(qǐng)求傳遞數(shù)據(jù)文章來源:http://www.zghlxwxcb.cn/news/detail-742845.html
-d
:設(shè)置請(qǐng)求參數(shù)(拼接參數(shù)或json)
curl -X POST http://example.com -d "firstname=John&lastname=Andrew"
-H
:設(shè)置request里的header
curl -X POST http://example.com -d '{"hello": "world"}' -H 'Content-Type: application/json'
-F
:模擬HTTP表單數(shù)據(jù)提交 multipart POST- 使用該-F選項(xiàng)時(shí),curl使用的默認(rèn)Content-Type是“multipart/form-data”
curl -X POST http://example.com -F 'name=Jason' -F 'email=jason@example.com'
get請(qǐng)求
帶參數(shù)請(qǐng)求,參數(shù)用&連接文章來源地址http://www.zghlxwxcb.cn/news/detail-742845.html
curl http://127.0.0.1:8080/login?admin&passwd=12345678
到了這里,關(guān)于curl命令行發(fā)送post/get請(qǐng)求的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!