curl url

  • 作用:获取页面内容或接口响应
    1. curl https://act.vip.iqiyi.com/api/process.action?cb=cb_1540200657317\&cid=afbe8fd3d73448c9\&interfaceCode=b5018a28d5f8609f\&pid=92b01a8207f5c404
    返回值
    1. var cb_1540200657317={"code":"Q00304","data":{},"msg":"用户未登录"}

curl -I url

  • 作用:获取请求页面或接口的请求头信息
    1. curl -I https://act.vip.iqiyi.com/api/process.action?cb=cb_1540200657317\&cid=afbe8fd3d73448c9\&interfaceCode=b5018a28d5f8609f\&pid=92b01a8207f5c404
    返回值
    1. [root@simonsfan code]# curl -I https://act.vip.iqiyi.com/api/process.action?cb=cb_1540200657317\&cid=afbe8fd3d73448c9\&interfaceCode=b5018a28d5f8609f\&pid=92b01a8207f5c404
    2. HTTP/1.1 200
    3. Server: nginx
    4. Date: Mon, 22 Oct 2018 09:45:52 GMT
    5. Content-Type: text/plain;charset=UTF-8
    6. Content-Length: 72
    7. Connection: keep-alive
    8. Accept-Charset: big5, big5-hkscs, cesu-8, euc-jp, euc-kr, gb18030, gb2312, gbk, ibm-thai, ibm00858, ibm01140, ibm01141, ibm01142, ibm01143, ibm01144, ibm01145, ibm01146, ibm01147, ibm01148, ibm01149, ibm037, ibm1026, ibm1047, ibm273, ibm277, ibm278, ibm280, ibm284, ibm285, ibm290, ibm297, ibm420, ibm424, ibm437, ibm500, ibm775, ibm850, ibm852, ibm855, ibm857, ibm860, ibm861, ibm862, ibm863, ibm864, ibm865, ibm866, ibm868, ibm869, ibm870, ibm871, ibm918, iso-2022-cn, iso-2022-jp, iso-2022-jp-2, iso-2022-kr, iso-8859-1, iso-8859-13, iso-8859-15, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-9, jis_x0201, jis_x0212-1990, koi8-r, koi8-u, shift_jis, tis-620, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-32be, utf-32le, utf-8, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, windows-31j, x-big5-hkscs-2001, x-big5-solaris, x-compound_text, x-euc-jp-linux, x-euc-tw, x-eucjp-open, x-ibm1006, x-ibm1025, x-ibm1046, x-ibm1097, x-ibm1098, x-ibm1112, x-ibm1122, x-ibm1123, x-ibm1124, x-ibm1166, x-ibm1364, x-ibm1381, x-ibm1383, x-ibm300, x-ibm33722, x-ibm737, x-ibm833, x-ibm834, x-ibm856, x-ibm874, x-ibm875, x-ibm921, x-ibm922, x-ibm930, x-ibm933, x-ibm935, x-ibm937, x-ibm939, x-ibm942, x-ibm942c, x-ibm943, x-ibm943c, x-ibm948, x-ibm949, x-ibm949c, x-ibm950, x-ibm964, x-ibm970, x-iscii91, x-iso-2022-cn-cns, x-iso-2022-cn-gb, x-iso-8859-11, x-jis0208, x-jisautodetect, x-johab, x-macarabic, x-maccentraleurope, x-maccroatian, x-maccyrillic, x-macdingbat, x-macgreek, x-machebrew, x-maciceland, x-macroman, x-macromania, x-macsymbol, x-macthai, x-macturkish, x-macukraine, x-ms932_0213, x-ms950-hkscs, x-ms950-hkscs-xp, x-mswin-936, x-pck, x-sjis_0213, x-utf-16le-bom, x-utf-32be-bom, x-utf-32le-bom, x-windows-50220, x-windows-50221, x-windows-874, x-windows-949, x-windows-950, x-windows-iso2022jp
    9. Access-Control-Allow-Credentials: true
    10. X-Frame-Options: SAMEORIGIN
    上述命令只会返回请求头信息,而不包含响应内容,可以使用 -l 参数来返回请求头和响应信息: ```bash [root@simonsfan code]# curl -i https://act.vip.iqiyi.com/api/process.action?cb=cb_1540200657317\&cid=afbe8fd3d73448c9\&interfaceCode=b5018a28d5f8609f\&pid=92b01a8207f5c404 HTTP/1.1 200 Server: nginx Date: Mon, 22 Oct 2018 09:47:35 GMT Content-Type: text/plain;charset=UTF-8 Content-Length: 72 Connection: keep-alive Accept-Charset: big5, big5-hkscs, cesu-8, euc-jp, euc-kr, gb18030, gb2312, gbk, ibm-thai, ibm00858, ibm01140, ibm01141, ibm01142, ibm01143, ibm01144, ibm01145, ibm01146, ibm01147, ibm01148, ibm01149, ibm037, ibm1026, ibm1047, ibm273, ibm277, ibm278, ibm280, ibm284, ibm285, ibm290, ibm297, ibm420, ibm424, ibm437, ibm500, ibm775, ibm850, ibm852, ibm855, ibm857, ibm860, ibm861, ibm862, ibm863, ibm864, ibm865, ibm866, ibm868, ibm869, ibm870, ibm871, ibm918, iso-2022-cn, iso-2022-jp, iso-2022-jp-2, iso-2022-kr, iso-8859-1, iso-8859-13, iso-8859-15, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-9, jis_x0201, jis_x0212-1990, koi8-r, koi8-u, shift_jis, tis-620, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-32be, utf-32le, utf-8, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, windows-31j, x-big5-hkscs-2001, x-big5-solaris, x-compound_text, x-euc-jp-linux, x-euc-tw, x-eucjp-open, x-ibm1006, x-ibm1025, x-ibm1046, x-ibm1097, x-ibm1098, x-ibm1112, x-ibm1122, x-ibm1123, x-ibm1124, x-ibm1166, x-ibm1364, x-ibm1381, x-ibm1383, x-ibm300, x-ibm33722, x-ibm737, x-ibm833, x-ibm834, x-ibm856, x-ibm874, x-ibm875, x-ibm921, x-ibm922, x-ibm930, x-ibm933, x-ibm935, x-ibm937, x-ibm939, x-ibm942, x-ibm942c, x-ibm943, x-ibm943c, x-ibm948, x-ibm949, x-ibm949c, x-ibm950, x-ibm964, x-ibm970, x-iscii91, x-iso-2022-cn-cns, x-iso-2022-cn-gb, x-iso-8859-11, x-jis0208, x-jisautodetect, x-johab, x-macarabic, x-maccentraleurope, x-maccroatian, x-maccyrillic, x-macdingbat, x-macgreek, x-machebrew, x-maciceland, x-macroman, x-macromania, x-macsymbol, x-macthai, x-macturkish, x-macukraine, x-ms932_0213, x-ms950-hkscs, x-ms950-hkscs-xp, x-mswin-936, x-pck, x-sjis_0213, x-utf-16le-bom, x-utf-32be-bom, x-utf-32le-bom, x-windows-50220, x-windows-50221, x-windows-874, x-windows-949, x-windows-950, x-windows-iso2022jp Access-Control-Allow-Credentials: true X-Frame-Options: SAMEORIGIN

var cb_1540200657317={“code”:”Q00304”,”data”:{},”msg”:”用户未登录”}


<a name="T7v50"></a>
### **curl  -d  "params" url**

- 作用:使用-d发送带参数的请求(默认是post方式提交)
```bash
curl -d "cb=cb_1540200657317&cid=afbe8fd3d73448c9&interfaceCode=b5018a28d5f8609f&pid=92b01a8207f5c404" https://act.vip.iqiyi.com/api/process.action

返回

var cb_1540200657317={"code":"Q00304","data":{},"msg":"用户未登录"}

curl -H Head_infos

  • 作用:自定义Header头信息


curl -L url

  • 作用:跟踪链接url重定向,有些页面或接口被重定向,直接使用curl url会返回 ```html

    301 Moved Permanently


    nginx/1.14.0
<a name="VvleJ"></a>
### **curl  -O  url……**

- 作用:下载指定资源文件到当前目录中
```bash
curl -O http://sr4.pplive.cn/cms/15/70/0dbb8ec002f1353e487d13fd949727a3.jpg  -O   http://sr4.pplive.cn/cms/39/88/4441be4257c21285c504509e479a43ea.jpg

如约智惠
您身边的生活助手
如约智惠.jpg