C:\Users\Administrator>curl -A "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; PerplexityBot/1.0; +https://perplexity.ai/perplexitybot)" https://www.5adanci.com
curl: (56) Recv failure: Connection was reset
C:\Users\Administrator>curl -A "Mozilla/5.0 AppleWebKit/537.36 (KHTML)" https://www.5adanci.com
**curl = 命令行 HTTP 客户端工具**
简单说:在 CMD/PowerShell/Linux 终端里,不用浏览器,直接发网页请求、看返回、看状态码(301/403/503)、看响应头。
常用于:
- 测试 301 跳转、HTTPS、IIS rewrite 规则
- 爬虫 UA 测试、接口调试
- 看服务器返回什么、有没有拦截
---
### `-A`(大写 A)
全称:`--user-agent`
作用:**伪造请求头里的 User-Agent(UA)**,告诉服务器 “我是什么客户端”(浏览器 / 爬虫)。
语法:
```
curl -A "这里写UA字符串" 网址
```
你这条:
```
curl -A "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; PerplexityBot/1.0; +https://perplexity.ai/perplexitybot)" https://www.5adanci.com
```
含义:**假装自己是 PerplexityBot 爬虫去访问你的网站**
>
> ❗注意区分:
>
>
> - `-A`(大写):User-Agent ✅ 你现在用的
> - `-a`(小写 a):`--append`,上传文件追加,几乎不用,**不是 UA**,很多人容易搞混
### 常用配套参数(你经常会用到)
- `-v`:verbose,详细模式,打印握手、请求头、响应头,排错神器
```
curl -v -A "xxx" shturl.cc/5Mp7l
```
- `-I`:大写的I, 只拿响应头(HEAD 请求,不下载页面内容),专门看 301、503、403
```
curl -I -A "xxx" shturl.cc/5Mp7l
```
- `-L`:自动跟随 301 跳转
```
curl -I -L shturl.cc/5Mp7l
```
### 一句话总结
`curl`:命令行浏览器;
`-A`:伪装 UA(爬虫 / 浏览器标识);
D:\Funcs2027\FuncWuXing\FuncWuXing\bin>curl -I -A "Mozilla/5.0 AppleWebKit/537.36 (KHTML***)" https://www.5adanci.com
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 21800
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
Set-Cookie: ASP.NET_SessionId=4mpvztvl103zzofsakvpd0sg; path=/; HttpOnly; SameSite=Lax
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 24 Nov 2026 15:06:32 GMT
D:\Funcs2027\FuncWuXing\FuncWuXing\bin>
D:\Funcs2027\FuncWuXing\FuncWuXing\bin>curl -A "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; PerplexityBot/1.0; +https://perplexity.ai/perplexitybot)" https://www.5adanci.com
curl: (56) Recv failure: Connection was reset
在web.config 中加了 rule ,禁止一些无效的爬虫访问
<rule name="BlockBotByUA" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_USER_AGENT}" pattern="PerplexityBot|Perplexity-User|CogBot|ExaSearchBot|GPTBot|ClaudeBot|AnthropicBot|ByteSpider" ignoreCase="true" />
</conditions>
<action type="AbortRequest" />
</rule>
D:\Funcs2027\FuncWuXing\FuncWuXing\bin>