linux curl命令详解及实例分享

2019-10-14 13:24:44丽君

  curl: (22) The requested URL returned error: 404

  [root@krlcgcms01 mytest]# curl //www.jb51.net/asdf

  <HTML><HEAD><TITLE>404,not found</TITLE>

  。。。。。。。。。。。。

  9,伪造来源地址,有的网站会判断,请求来源地址。

  [root@krlcgcms01 mytest]# curl -e http://localhost //www.jb51.net/wp-login.php

  [root@krlcgcms01 mytest]# curl -e http://localhost //www.jb51.net/wp-login.php

  10,当我们经常用curl去搞人家东西的时候,人家会把你的IP给屏蔽掉的,这个时候,我们可以用代理

  [root@krlcgcms01 mytest]# curl -x 24.10.28.84:32779 -o home.html //www.jb51.net

  [root@krlcgcms01 mytest]# curl -x 24.10.28.84:32779 -o home.html //www.jb51.net
11,比较大的东西,我们可以分段下载

  [root@krlcgcms01 mytest]# curl -r 0-100 -o img.part1 //www.jb51.net/wp-

  content/uploads/2010/09/compare_varnish.jpg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

  Dload  Upload   Total   Spent    Left  Speed

  100   101  100   101    0     0    105      0 --:--:-- --:--:-- --:--:--     0

  [root@krlcgcms01 mytest]# curl -r 100-200 -o img.part2 //www.jb51.net/wp-

  content/uploads/2010/09/compare_varnish.jpg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

  Dload  Upload   Total   Spent    Left  Speed

  100   101  100   101    0     0     57      0  0:00:01  0:00:01 --:--:--     0

  [root@krlcgcms01 mytest]# curl -r 200- -o img.part3 //www.jb51.net/wp-

  content/uploads/2010/09/compare_varnish.jpg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

  Dload  Upload   Total   Spent    Left  Speed

  100  104k  100  104k    0     0  52793      0  0:00:02  0:00:02 --:--:-- 88961

  [root@krlcgcms01 mytest]# ls |grep part | xargs du -sh

  4.0K    one.part1

  112K    three.part3

  4.0K    two.part2

  [root@krlcgcms01 mytest]# curl -r 0-100 -o img.part1 //www.jb51.net/wp-

  content/uploads/2010/09/compare_varnish.jpg