在Web开发的世界里,选择合适的工具可以大大提高工作效率,改善代码质量,并加快项目进度。以下是一些常用的Web开发工具,涵盖了从设计到部署的各个环节。
Web 相关工具
links
格式:
links [OPTION]... [URL]...
常用选项:
-dump 非交互式模式,显示输出结果-source 打印源码
wget
格式:
wget [OPTION]... [URL]...
常用选项
#启动
-V, -version 显示wget的版本后退出
-h, -help 打印语法帮助
-b, -background 启动后转入后台执行
-e, -execute=COMMAND 执行`.wgetrc'格式的命令,wgetrc格式参见/etc/wgetrc或~/.wgetrc
#记录和输入文件
-o, -output-file=FILE 把记录写到FILE文件中
-a, -append-output=FILE 把记录追加到FILE文件中
-d, -debug 打印调试输出
-q, -quiet 安静模式(没有输出)
-v, -verbose 冗长模式(这是缺省设置)
-nv, -non-verbose 关掉冗长模式,但不是安静模式
-i, -input-file=FILE 下载在FILE文件中出现的URLs
-F, -force-html 把输入文件当作HTML格式文件对待
-B, -base=URL 将URL作为在-F -i参数指定的文件中出现的相对链接的前缀
-sslcertfile=FILE 可选客户端证书
-sslcertkey=KEYFILE 可选客户端证书的KEYFILE
-egd-file=FILE 指定EGD socket的文件
#下载
-bind-address=ADDRESS 指定本地使用地址(主机名或IP,当本地有多个IP或名字时使用)
-t, -tries=NUMBER 设定最大尝试链接次数(0 表示无限制).
-O -output-document=FILE 把文档写到FILE文件中
-nc, -no-clobber 不要覆盖存在的文件或使用.#前缀
-c, -continue 接着下载没下载完的文件-progress=TYPE 设定进程条标记
-N, -timestamping 不要重新下载文件除非比本地文件新
-S, -server-response 打印服务器的回应
-spider 不下载任何东西
-T, -timeout=SECONDS 设定响应超时的秒数
-w, -wait=SECONDS 两次尝试之间间隔SECONDS秒
-waitretry=SECONDS 在重新链接之间等待1…SECONDS秒
-random-wait 在下载之间等待0…2*WAIT秒
-Y, -proxy=on/off 打开或关闭代理
-Q, -quota=NUMBER 设置下载的容量限制
-limit-rate=RATE 限定下载输率
#目录
-nd -no-directories 不创建目录
-x, -force-directories 强制创建目录
-nH, -no-host-directories 不创建主机目录
-P, -directory-prefix=PREFIX 将文件保存到目录 PREFIX/…
-cut-dirs=NUMBER 忽略 NUMBER层远程目
#HTTP 选项
-http-user=USER 设定HTTP用户名为 USER.
-http-passwd=PASS 设定http密码为 PASS.
-C, -cache=on/off 允许/不允许服务器端的数据缓存 (一般情况下允许).
-E, -html-extension 将所有text/html文档以.html扩展名保存
-ignore-length 忽略 `Content-Length'头域
-header=STRING 在headers中插入字符串 STRING
-proxy-user=USER 设定代理的用户名为 USER
-proxy-passwd=PASS 设定代理的密码为 PASS
-referer=URL 在HTTP请求中包含 `Referer: URL'头
-s, -save-headers 保存HTTP头到文件
-U, -user-agent=AGENT 设定代理的名称为 AGENT而不是 Wget/VERSION.
-no-http-keep-alive 关闭 HTTP活动链接 (永远链接).
-cookies=off 不使用 cookies.
-load-cookies=FILE 在开始会话前从文件 FILE中加载cookie
-save-cookies=FILE 在会话结束后将 cookies保存到 FILE文件中
#FTP 选项
-nr, -dont-remove-listing 不移走 '.listing'文件
-g, -glob=on/off 打开或关闭文件名的 globbing机制
-passive-ftp 使用被动传输模式 (缺省值).
-active-ftp 使用主动传输模式
-retr-symlinks 在递归的时候,将链接指向文件(而不是目录)
#递归下载
-r, -recursive 递归下载--慎用!
-l, -level=NUMBER 最大递归深度 (inf 或 0 代表无穷).
-delete-after 在现在完毕后局部删除文件
-k, -convert-links 转换非相对链接为相对链接
-K, -backup-converted 在转换文件X之前,将之备份为 X.orig
-m, -mirror 等价于 -r -N -l inf -nr.
-p, -page-requisites 下载显示HTML文件的所有图片
#递归下载中的包含和不包含(accept/reject)
-A, -accept=LIST 分号分隔的被接受扩展名的列表
-R, -reject=LIST 分号分隔的不被接受的扩展名的列表
-D, -domains=LIST 分号分隔的被接受域的列表
-exclude-domains=LIST 分号分隔的不被接受的域的列表
-follow-ftp 跟踪HTML文档中的FTP链接
-follow-tags=LIST 分号分隔的被跟踪的HTML标签的列表
-G, -ignore-tags=LIST 分号分隔的被忽略的HTML标签的列表
-H, -span-hosts 当递归时转到外部主机
-L, -relative 仅仅跟踪相对链接
-I, -include-directories=LIST 允许目录的列表
-X, -exclude-directories=LIST 不被包含目录的列表
-np, -no-parent 不要追溯到父目录
常用选项
-q 静默模式
-c 断点续传
-P /path 保存在指定目录
-O filename 保存为指定文件名,filename 为 - 时,发送至标准输出
--limit-rate= 指定传输速率,单位K,M等
示例
[root@ubuntu2404 ~]#wget --limit-rate=1M -P /data https://mirrors.aliyun.com/ubuntu-releases/25.04/ubuntu-25.04-live-server-amd64.iso
--2025-08-24 12:42:25-- https://mirrors.aliyun.com/ubuntu-releases/25.04/ubuntu-25.04-live-server-amd64.iso
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 111.12.220.67, 111.47.122.98, 117.161.180.77, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|111.12.220.67|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2021750784 (1.9G) [application/x-cd-image]
Saving to: ‘/data/ubuntu-25.04-live-server-amd64.iso’
ubuntu-25.04-live-server-amd64.iso 0%[ ] 1.67M 505KB/s eta 68m 7s
实现浏览器功能
[root@ubuntu2404 ~]#wget -qO - http://192.168.1.20/
下载指定目录
[root@ubuntu2404 ~]#wget -r -np -nH -R index.html http://www.example.com/dir/
[root@ubuntu2404 ~]#wget -c -r -np -k -L -p http://www.example.com/dir/
-r : 遍历所有子目录
-np : 不到上一层子目录去
-nH : 不要将文件保存到主机名文件夹
-R index.html : 不下载 index.html 文件
curl
curl是基于URL语法在命令行方式下工作的文件传输工具,它支持FTP,FTPS,HTTP,HTTPS, GOPHER,TELNET,DICT,FILE及LDAP等协议。curl支持HTTPS认证,并且支持HTTP的POST、PUT等方法, FTP上传, kerberos认证,HTTP上传,代理服务器,cookies,用户名/密码认证, 下载文件断点续传,上载文件断点续传,http代理服务器管道( proxy tunneling),还支持IPv6,socks5代理服务器,通过http代理服务器上传文件到FTP服务器等,功能十分强大
格式:
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> 允许最大传输时间
示例
[root@ubuntu2404 ~]#curl -I http://www.163.com
HTTP/1.1 200 OK
Server: Tengine
Content-Type: text/html; charset=utf-8
Content-Length: 258354
Connection: keep-alive
Date: Sun, 24 Aug 2025 04:50:55 GMT
Vary: special-area
Expires: Sun, 24 Aug 2025 04:52:15 GMT
Cache-Control: no-cache,no-store,private
Via: cache2.l2cn3022[42,0,200-0,C], cache2.l2cn3022[7,0], vcache21.cn5463[0,0,200-0,H], vcache14.cn5463[3,0]
X-Ali-Tproxy-Consistent-Hash-Hot: 1
Age: 10
Ali-Swift-Global-Savetime: 1756011055
X-Cache: HIT TCP_MEM_HIT dirn:-2:-2
X-Swift-SaveTime: Sun, 24 Aug 2025 04:50:55 GMT
X-Swift-CacheTime: 30
X-Cache-Remote: HIT
cdn-user-ip: 223.160.172.142
cdn-source: Ali
cdn-ip: 112.46.175.110
Timing-Allow-Origin: *
EagleId: 702eaf2217560110653511953e
[root@ubuntu2404 ~]#curl -I -A ie10 http://www.163.com
HTTP/1.1 200 OK
Server: Tengine
Content-Type: text/html; charset=utf-8
Content-Length: 53241
Connection: keep-alive
Date: Sun, 24 Aug 2025 04:51:55 GMT
Vary: special-area
Expires: Sun, 24 Aug 2025 04:53:15 GMT
Cache-Control: no-cache,no-store,private
Content-Encoding: gzip
Via: cache74.l2cn3022[46,4,200-0,C], cache27.l2cn3022[6,0], vcache21.cn5463[0,0,200-0,H], vcache15.cn5463[2,0]
Age: 2
Ali-Swift-Global-Savetime: 1756011115
X-Cache: HIT TCP_MEM_HIT dirn:-2:-2
X-Swift-SaveTime: Sun, 24 Aug 2025 04:51:55 GMT
X-Swift-CacheTime: 30
X-Cache-Remote: HIT
cdn-user-ip: 223.160.172.142
cdn-source: Ali
cdn-ip: 112.46.175.94
Timing-Allow-Origin: *
EagleId: 702eaf2317560111170032767e
[root@ubuntu2404 ~]#curl -H "user-agent: firefox" http://www.163.com
示例:判断网站正常
[root@ubuntu2404 ~]#if [ "$(curl -sL -w '%{http_code}' http://www.caoge.com -o /dev/null)" = "200" ]; then
echo "Success"
else
echo "Fail"
fi
[root@ubuntu2404 ~]#if curl -sL --fail http://www.caoge.com -o /dev/null;
then
echo "Success"
else
echo "Fail"
fi
示例:利用curl 获取响应码和远程主机IP
[root@ubuntu2404 ~]#curl -s -I -m10 -o /dev/null -w %{http_code} http://www.baidu.com/
200
[root@ubuntu2404 ~]#curl -s -I -m10 -o /dev/null -w %{remote_ip} http://caoge.com/
58.87.87.99
[root@ubuntu2404 ~]#curl -s -I -m10 -o /dev/null -w %{local_ip} http://caoge.com/
192.168.1.20
[root@ubuntu2404 ~]#curl -s -I -m10 -o /dev/null -w %{local_port} http://caoge.com/
45304
[root@ubuntu2404 ~]#curl -s -I -m10 -o /dev/null -w %{remote_port} http://caoge.com/
80
httpie
HTTPie 工具是功能丰富的 HTTP 命令行客户端,它能通过命令行界面与 Web 服务进行交互。它提供一个简单的 http 命令,允许使用简单而自然的语法发送任意的 HTTP 请求,并会显示彩色的输出。
HTTPie 能用于测试、调试及与 HTTP 服务器交互。
主要特点:
具表达力的和直观语法格式化的及彩色化的终端输出内置 JSON 支持表单和文件上传HTTPS、代理和认证任意请求数据自定义头部持久化会话类似 wget 的下载支持 Python 2.7 和 3.x
官方网站:https://httpie.org
安装: Ubuntu
[root@ubuntu2404 ~]# apt update && apt -y install httpie
安装:基于EPEL
yum install httpie -y
查看帮助
[root@ubuntu2404 ~]#http --help
usage:
http [METHOD] URL [REQUEST_ITEM ...]
HTTPie: modern, user-friendly command-line HTTP client for the API era. <https://httpie.io>
Positional arguments:
These arguments come after any flags and in the order they are listed here.
Only URL is required.
METHOD
The HTTP method to be used for the request (GET, POST, PUT, DELETE, ...).
This argument can be omitted in which case HTTPie will use POST if there
is some data to be sent, otherwise GET:
$ http example.org # => GET
$ http example.org hello=world # => POST
URL
The request URL. Scheme defaults to 'http://' if the URL
does not include one. (You can override this with: --default-scheme=http/https)
You can also use a shorthand for localhost
$ http :3000 # => http://localhost:3000
$ http :/foo # => http://localhost/foo
REQUEST_ITEM
Optional key-value pairs to be included in the request. The separator used
determines the type:
':' HTTP headers:
Referer:https://httpie.io Cookie:foo=bar User-Agent:bacon/1.0
'==' URL parameters to be appended to the request URI:
search==httpie
'=' Data fields to be serialized into a JSON object (with --json, -j)
or form data (with --form, -f):
name=HTTPie language=Python description='CLI HTTP client'
':=' Non-string JSON data fields (only with --json, -j):
awesome:=true amount:=42 colors:='["red", "green", "blue"]'
'@' Form file fields (only with --form or --multipart):
cv@~/Documents/CV.pdf
cv@'~/Documents/CV.pdf;type=application/pdf'
'=@' A data field like '=', but takes a file path and embeds its content:
essay=@Documents/essay.txt
示例
#显示信息(包含响应头200)
http www.baidu.com
#显示详细的请求(包含请求和返回头200)
http -v www.baidu.com
#只显示Header
http -h www.baidu.com
http --head www.baidu.com
http --header www.baidu.com
http --headers www.baidu.com
# 只显示Body
http -bwww.baidu.com
http --body baidu.com
# 下载文件
http -d www.baidu.com
# 模拟提交表单
http -f POST www.baidu.com username='wang'
# 请求删除的方法
http DELETE www.baidu.com
# 传递JSON数据请求(默认就是JSON数据请求)
http PUT www.baidu.com username='wang' password='123456'
# 如果JSON数据存在不是字符串则用:=分隔,例如
http PUT www.baidu.com 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.baidu.com username='wang'
# 模拟Form的上传, Content-Type: multipart/form-data
http -f POST www.baidu.com/jobs username='wang' file@~/test.pdf
# 修改请求头, 使用:分隔
http www.baidu.com User-Agent:wang-agent/1.0 'Cookie:a=b;b=c'
Referer:http://www.google.com/
# 认证
http -a username:password www.baidu.com
http -A basic -a username:password www.baidu.com
# 使用http代理
http --proxy=http:http://172.16.0.100:8081 proxy.wang.org
http --proxy=http:http://user:pass@172.16.0.100:8081 proxy.wang.org
http --proxy=https:http://172.16.0.100:8118 proxy.wang.org
http --proxy=https:http://user:pass@172.16.0.100:8118 proxy.wang.org
示例:查看信息及响应头
[root@ubuntu2404 ~]# http 192.168.1.20/test.html
示例:查看请示和响应头部及信息
[root@ubuntu2404 ~]# http -v 192.168.1.20/test.html
示例:查看响应报文头部
[root@ubuntu2404 ~]# http HEAD http://www.baidu.com
HTTP/1.1 200 OK
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html
Date: Sun, 24 Aug 2025 05:11:17 GMT
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Tr_id: bfe_8851431937266012385
示例:查看请求和响应报文头部
[root@ubuntu2404 ~]#http -p Hh http://www.baidu.com
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: www.baidu.com
User-Agent: HTTPie/3.2.2
HTTP/1.1 200 OK
Bdpagetype: 1
Bdqid: 0xf5df16ba03508dbc
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Sun, 24 Aug 2025 05:12:16 GMT
P3p: CP=" OTI DSP COR IVA OUR IND COM "
P3p: CP=" OTI DSP COR IVA OUR IND COM "
Server: BWS/1.1
Set-Cookie: BAIDUID=B988FD4D7AF4B88AF961E29E546EC61F:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BIDUPSID=B988FD4D7AF4B88AF961E29E546EC61F; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: PSTM=1756012336; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BAIDUID=B988FD4D7AF4B88A3A629147A76C4CC0:FG=1; max-age=31536000; expires=Mon, 24-Aug-26 05:12:16 GMT; domain=.baidu.com; path=/; version=1; comment=bd
Set-Cookie: BDSVRTM=4; path=/
Set-Cookie: BD_HOME=1; path=/
Tr_id: super_0xf5df16ba03508dbc
Traceid: 1756012336259628801017716904447274159548
Transfer-Encoding: chunked
X-Ua-Compatible: IE=Edge,chrome=1
X-Xss-Protection: 1;mode=block
示例:指定请求头部的首部字段
[root@ubuntu2404 ~]#http -p H http://www.jd.com User-Agent:wangtest Referer:http://www.baidu.com
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: www.jd.com
Referer: http://www.baidu.com
User-Agent: wangtest
示例:下载资源
方式1
[root@ubuntu2404 ~]#http https://i-blog.csdnimg.cn/blog_migrate/ef75395084be938204506600f29dcc3c.jpeg >log.jpeg
[root@ubuntu2404 ~]#ls
log.jpeg
[root@ubuntu2404 ~]#file log.jpeg
log.jpeg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1700x1000, components 3
#方法2
[root@ubuntu2404 ~]#http --download https://i-blog.csdnimg.cn/blog_migrate/ef75395084be938204506600f29dcc3c.jpeg
HTTP/1.1 200 OK
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Cache-Control: max-age=2592000
Connection: keep-alive
Content-Disposition: inline
Content-Length: 231691
Content-Type: image/jpeg
Date: Sun, 24 Aug 2025 05:21:35 GMT
ETag: "2fd90b6176c00bffc667b214a7f8c00f"
Last-Modified: Fri, 13 Sep 2024 02:58:58 GMT
Server: OBS
X-Ser: i11595_c17989, i90618_c20401
x-obs-id-2: 36AAAQAAEAABAAAQAAEAABAAAQAAEAABAAAaI=AAAAAAAAAAAAAAAAAAAAAAAAAA
x-obs-request-id: 000001987D97FBE7EAE62C4F66DAE6DF
x-obs-tagging-count: 0
Downloading to ef75395084be938204506600f29dcc3c.jpeg
Done. 231.7 kB in 00:0.15263 (1.5 MB/s)
示例:用POST方法提交json格式的数据
[root@ubuntu2404 ~]# http http://www.baidu.com user=wang password=wang
示例:用POST方法,指交表单数据
[root@ubuntu2404 ~]# http -f POST http://www.baidu.com user=wang password=wang
压力测试工具
httpd的压力测试工具:
ab, webbench, http_load, seigeJmeter 开源Loadrunner 商业,有相关认证tcpcopy:网易,复制生产环境中的真实请求,并将之保存
ab 来自httpd-tools包
命令格式
ab [OPTIONS] URL
常见选项:
-n:总请求数
-c:模拟的并发数
-k:以持久连接模式测试
说明:并发数高于1024时,需要用 ulimit -n # 调整能打开的文件数
总结
随着Web技术的不断进步,相关的开发工具也在不断地演进和完善。选择适合自己工作流程和个人偏好的工具,能够极大地提升开发效率和产品质量。希望本文介绍的这些工具能为你带来一些启发,并帮助你在Web开发的道路上走得更远。无论你是运维还是有经验的开发者,都可以根据自己的需求从中找到合适的工具来辅助你的开发工作。
















暂无评论内容