• linux curl 命令


    [root@localhost ~]# curl www.baidu.com                               # 访问百度,访问出来的内容是源代码
    [root@localhost ~]# curl -I www.baidu.com                            # -I 用于表示访问 http 首部信息
    [root@localhost ~]# curl -u username:password http://www.xxxx.com    # -u 用于访问需要验证的网页
    [root@localhost ~]# curl -O https://www.baidu.com/img/bd_logo1.png   # -O 用于下载网页上的资源,功能与 wget 一致
    [root@localhost ~]# curl -o baidu.png https://xxx/bd_logo1.png       # -o 用于下载并重命名

    命令参数:

    -I    # 只显示指定页面的头部信息,用法如:curl -I http://www.baidu.com/
    -o    # 把输出保存到指定的文件中,用法如:curl -o index.html http://www.baidu.com/
    -O    # 把输出保存到文件中,这个文件名取自URL中的文件名,如:curl -O http://www.baidu.com/abc.html 会保存一个abc.html文件
          # 该参数的另一种用法是可以循环下载文件,比如:curl -O http://www.baidu.com/[1-5].jpg 可以把 1.jpg 2.jpg ... 下载下来
    -d    # 用法发送POST请求,与-X连用,用法如:curl -d "user=tom&pass=123" -X POST http://www.baidu.com/
    -X    # 指定发送数据的方式,与-d连用,用法如:curl -d "user=tom&pass=123" -X POST http://www.baidu.com/
    -C    # 断点续传,防止下载到一半失败,用法如:curl -C - -O http://www.baidu.com/index.html,其中的"-"是让curl自动找到在哪里恢复续传
    -L    # 下载重定向后的网页,用法如:curl -L http://www.baidu.com/ 参考:https://www.jb51.net/article/118402.htm
    -A    # 自定义用户代理(User-Agent)来获取页面,用法如:curl -A "Mozilla/5.0 ... Firefox/35.0" http://www.baidu.com/
    -x    # 自定义代理服务器来获取页面,用法如:curl -x 192.168.100.100:1080 http://www.baidu.com/
    -c    # 用于保存cookie信息到指定的文件,用法如:curl -c cookie.txt http://www.baidu.com
    -D    # 用于保存header信息到指定的文件,用法如:curl -D header.txt http://www.baidu.com/
    -b    # 使用指定的cookie文件来获取页面,用法如:curl -b cookie.txt http://www.baidu.com/
    -e    # 伪造盗链(referer)来获取页面,用法如:curl -e "www.linux.com" http://www.baidu.com/
    -u    # 使用用户名和密码来下载需要授权的页面,用法如:curl -u username:password http://www.baidu.com/
    -#    # 下载页面的同时显示进度条,与--progress用法一致,用法如:curl -# -O http://www.baidu.com/index.html
    -s/--silent     # 下载页面时不显示进度条,用法如:curl --silent -O http://www.baidu.com/index.html
    --progress      # 下载页面时显示进度条,用法如:curl --progress -O http://www.baidu.com/index.html
    --limit-rate    # 限制下载速度,用法如:curl --limit-rate 10M http://www.baidu.com/
  • 相关阅读:
    局部地区类似淘宝设想
    eclipse中安装GWT插件
    MYSQL数据库设计和数据库设计实例(三)
    MYSQL数据库设计和数据库设计实例(二)
    微软万维天文望远镜(Microsoft World Wide Telescope)
    html学习列表
    java中多线程学习一二点
    win7 64位下完美安装64位oracle 11g
    eclipse运行时不能自动保存的解决方法
    MYSQL数据库设计和数据库设计实例(一)
  • 原文地址:https://www.cnblogs.com/mingerlcm/p/8656342.html
Copyright © 2020-2023  润新知