zoukankan      html  css  js  c++  java
  • curl 使用指南

    curl 简介

    curl(CommandLine Uniform Resource Locator),命令行统一资源定位符。是一个利用 URL 规则在命令行下工作的文件传输工具。官方地址是:https://curl.haxx.se/

    curl 支持多个操作系统,下载安装非常简单。安装完后,使用下面命令查看使用帮助:

    D:Usersxxx>curl -h
    Usage: curl [options...] <url>
     -d, --data <data>   HTTP POST data
     -f, --fail          Fail silently (no output at all) on HTTP errors
     -h, --help <category> Get help for commands
     -i, --include       Include protocol response headers in the output
     -o, --output <file> Write to file instead of stdout
     -O, --remote-name   Write output to a file named as the remote file
     -s, --silent        Silent mode
     -T, --upload-file <file> Transfer local FILE to destination
     -u, --user <user:password> Server user and password
     -A, --user-agent <name> Send User-Agent <name> to server
     -v, --verbose       Make the operation more talkative
     -V, --version       Show version number and quit
    
    This is not the full help, this menu is stripped into categories.
    Use "--help category" to get an overview of all categories.
    For all options use the manual or "--help all".
    

    上面只是列出了部分使用帮助,查看全部使用帮助:curl --help all

    常用 curl 实例

    1. 访问 Restfull 接口

    curl -H "Content-Type: application/json" -H "referer: xxx" -X POST  --data '{"userName":"Jessica1989","agencyCode":2}' http://xx.xx.xx.xx:8080/admin/xx
    

    上面的命令以 Post 请求的方式,访问某接口,并在请求头中传了 referer 参数。

    忽略https证书校验

    加上-k参数

    curl -H "Content-Type: application/json" -H "referer: xxx" -X POST  --data '{"key1":"value1"}' -k https://203.156.238.218:20357
    

    参考

    人生的主旋律其实是苦难,快乐才是稀缺资源。在困难中寻找快乐,才显得珍贵~
  • 相关阅读:
    Guava教程
    Hibernate各种主键生成策略与配置详解
    JPA的坑多服务主键重复
    如何用redis来生成唯一Id
    【Gym 100712A】Who Is The Winner?
    【POJ 1416】Shredding Company
    【CodeForces 620D】Professor GukiZ and Two Arrays
    【CodeForces 621B】Wet Shark and Bishops
    【Gym 100015A】Another Rock-Paper-Scissors Problem
    【CodeForces 618B】Guess the Permutation
  • 原文地址:https://www.cnblogs.com/54chensongxia/p/13847035.html
Copyright © 2011-2022 走看看