links [OPTION]… [URL]…
wget [OPTION]… [URL]…
wget -P /opt/ https://nginx.org/download/nginx-1.24.0.tar.gz
wget -O /opt/aa.tar.gz https://nginx.org/download/nginx-1.24.0.tar.gz
wget --limit-rate 10K -P /data/ https://nginx.org/download/nginx-1.24.0.tar.gz #/data不存在会建立
wget -qO - https://baidu.com/ #将下载输出到标准输出
wget -r -np -nH -R index.html http://www.example.com/dir/
wget -c -r -np -k -L -p http://www.example.com/dir/
-r : 遍历所有子目录
-np : 不到上一层子目录去
-nH : 不要将文件保存到主机名文件夹,既不要 www.example.com/dir/... 目录结构 而是直接 dir/..
-R index.html : 不下载 index.html 文件
-k 选项的作用是在下载完成后,将 HTML 文件中的链接转换成本地链接,即修改文件中的链接,使之指向下载到本地的其他文件,而不是指向互联网上的地址
-p 下载显示 HTML 页面所需的所有资源。这包括如图像、CSS 和 JavaScript 等。使用 -p 确保网页在离线时能完整地显示,就像在线浏览时一样
-L 只跟踪相对链接。该选项告诉 wget 只应下载与原始URL相对的链接,忽略那些指向完全不同位置的绝对链接
curl [options] [URL…]
常见选项
-A/--user-agent <string> 设置用户代理发送给服务器
-e/--referer <URL> 来源网址
--cacert <file> CA证书 (SSL)
-k/--insecure 允许忽略证书进行 SSL 连接
--compressed 要求返回是压缩的格式
-H/--header "key:value” 自定义首部字段传递给服务器
-i 显示页面内容,包括报文首部信息
-I/--head 只显示响应报文首部信息
-D/--dump-header <file>将url的header信息存放在指定文件中
--basic 使用HTTP基本认证
-u/--user <user[:password]>设置服务器的用户和密码
-L 如果有3xx响应码,重新发请求到新位置
-O 使用URL中默认的文件名保存文件到本地
-o <file> 将网络文件保存为指定的文件中
--limit-rate <rate> 设置传输速度
-0/--http1.0 数字0,使用HTTP 1.0
-v/--verbose 更详细
-C 选项可对文件使用断点续传功能
-c/--cookie-jar <file name> 将url中cookie存放在指定文件中
-x/--proxy <proxyhost[:port]> 指定代理服务器地址
-X/--request <command> 向服务器发送指定请求方法
-U/--proxy-user <user:password> 代理服务器用户和密码
-T 选项可将指定的本地文件上传到FTP服务器上
--data/-d 方式指定使用POST方式传递数据
-s --silent Silent mode
-b name=data 从服务器响应set-cookie得到值,返回给服务器
-w <format> 显示相应的指定的报文信息,如:%{http_code},%{remote_ip}等
-m, --max-time <time> 允许最大传输时间
curl -I http://www.163.com #只显示头部信息
curl -I -A ie10 http://www.163.com # -A user-agent 指定浏览器类型
curl -H "user-agent: firefox" http://www.163.com #-H 指定标头K:V键值对
curl -sL -w '%{http_code}' http://baidu.com -o /dev/null #-s 安静 -L 执行重定向 -w 输出 '%{http_code}' -o 将curl body信息指定输出
curl -sL -m10 -w '%{remote_ip}' http://baidu.com -o /dev/null #-m最大传输时间10s , 显示远程主机ip
curl -sL -m10 -w '%{local_ip}' http://baidu.com -o /dev/null
curl -sL -m10 -w '%{local_port}' http://baidu.com -o /dev/null
curl -sL -m10 -w '%{remote_port}' http://baidu.com -o /dev/null
https://httpie.org
HTTPie 工具是功能丰富的 HTTP 命令行客户端,它能通过命令行界面与 Web 服务进行交互。它提供一 个简单的 http 命令,允许使用简单而自然的语法发送任意的 HTTP 请求,并会显示彩色的输出 HTTPie 能用于测试、调试及与 HTTP 服务器交互
ubuntu安装
apt update && apt -y install httpie
centos 基础 epel
yum install httpie -y
http blog.codeme.run
https blog.codeme.run
http -v blog.codeme.run #显示详细信息
# 只显示Header
http -h blog.codeme.run
http --head blog.codeme.run
http --header blog.codeme.run
http --headers blog.codeme.run
# 只显示Body
http -b blog.codeme.run
http --body blog.codeme.run
#下载文件
http -d https://nginx.org/download/nginx-1.24.0.tar.gz
# 模拟提交表单
http -f POST www.wang.org username='wang'
# 请求删除的方法
http DELETE www.wang.org
# 传递JSON数据请求(默认就是JSON数据请求)
http PUT www.wang.org username='wang' password='123456'
# 如果JSON数据存在不是字符串则用:=分隔,例如
http PUT www.wang.org username='wang' password='123456' age:=30 a:=true streets:='["a", "b"]'
# 模拟Form的Post请求, Content-Type: application/x-www-form-urlencoded; charset=utf-8
http --form POST www.wang.org username='wang'
# 模拟Form的上传, Content-Type: multipart/form-data
http -f POST www.wang.org/jobs username='wang' file@~/test.pdf
# 修改请求头, 使用:分隔
http www.wang.org User-Agent:wang-agent/1.0 'Cookie:a=b;b=c' Referer:http://www.google.com/
# 认证
http -a username:password www.wang.org
http -A basic -a username:password www.wang.org
# 使用http代理
http --proxy=http:http://172.16.0.100:8081 proxy.wang.org
http --proxy=http:http://user:[email protected]:8081 proxy.wang.org
http --proxy=https:http://172.16.0.100:8118 proxy.wang.org
http --proxy=https:http://user:[email protected]:8118 proxy.wang.org
#查看响应报文头部
http HEAD http://blog.codeme.run
http -v http://blog.codeme.run #请求和响应都可以查看
#查看请求和响应头部
http -p Hh http://blog.codeme.run
#指定请求的头部字段
http -p H http://www.wang.com User-Agent:wangtest Referer:http://www.baidu.com
telnet 10.0.0.3 443
如果结果是
Trying 10.0.0.3...
Connected to 10.0.0.3.
Escape character is '^]'.
说明10.0.0.3的443端口在打开着
nc -vz 10.0.0.3 443
这里-v表示启用详细模式,-z表示只扫描侦听守护程序,不发送任何数据
如果端口开放,你会看到如下输出:
Connection to 10.0.0.3 443 port [tcp/https] succeeded!
测试UDP端口不能这样使用
nc -vzu 10.0.0.3 443
-u 指定使用UDP协议
如果服务器端对UDP端口有特定的响应设置(如回应某些特定的UDP查询),则你可能能看到一些输出。如果没有响应,通常你不会收到任何信息,这使得仅通过nc来确定UDP端口是否开放变得比较困难
-n:总请求数
-c:模拟的并发数
-k:以持久连接模式测试
说明:并发数高于1024时,需要用 ulimit -n # 调整能打开的文件数
ab -c10 -n100 https://blog.codeme.run/
Concurrency Level: 10
Time taken for tests: 2.334 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 139290 bytes
HTML transferred: 22700 bytes
Requests per second: 42.85 [#/sec] (mean) #每秒并发请求数
Time per request: 233.356 [ms] (mean)
Time per request: 23.336 [ms] (mean, across all concurrent requests)
Transfer rate: 58.29 [Kbytes/sec] received