curl命令
curl命令是一个便利的发起http请求的工具。
1,安装操作请参考
https://blog.csdn.net/qq_27093465/article/details/53545693
2,Curl的使用
get请求,与保存
curl www.baidu.com curl "http://172.17.21.197:54321?pa1=hello" // 保存,下载 curl -o file.html www.baidu.com curl -o i.jpg http://img3.douban.com/lpic/s4549903.jpg // -A 仿造ie与运行平台 curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" www.baidu.com // -e 仿造入口链接(即referer,用于盗链) curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -e "www.google.com" www.baidu.com // -x 使用代理 curl -x a.b.c.d:54321 http://google.com // -D 保存cookie到文件 curl www.baidu.com -o aa.txt -D cookie.txt // -b 读取文件并当作cookie数据来请求 curl www.baidu.com -b cookie.txt // -H 设置请求头,这里设置了cookie跟ua curl -H "Cookie: install_id=14621691626; sid_guard=\"0eb878191489e4247f643672c932c814|1504782359|2592000|Sat\054 07-Oct-2017 11:05:59 GMT\"; \n User-Agent: xxx/1.5.6 (iPhone; iOS 10.2; Scale/2.00)" "https://xxx.yy.com/…"post
// -d 请求体 curl -d "user=nickwolfe&password=12345" http://www.linuxidc.com/login.cgi curl -d "key=jet" 192.168.2.32:54321
post,以表单的方式(multipart/form-data)
// "file"为key名,随便起,后面为文件路径(包括文件包) curl -F "file=@./myfile.ok" "http://172.17.xx.xx:54321"