第一步:robots.txt 配置
User-agent: GPTBot Disallow: / User-agent: ClaudeBot Disallow: / User-agent: anthropic-ai Disallow: / User-agent: Google-Extended Disallow: / User-agent: CCBot Disallow: /
这表示:
GPTBot(OpenAI)禁止访问
ClaudeBot(Anthropic)禁止访问
anthropic-ai(Claude 的另一个 UA)禁止访问
Google-Extended(Google AI 数据抓取)禁止访问
CCBot(Common Crawl)禁止访问
所有这些都是合法的 AI 爬虫,它们都会遵守 robots.txt。

2:NGINX中屏幕:把 UA 屏蔽规则放到 server{} 顶层
# 屏蔽 AI 爬虫
if ($http_user_agent ~* (GPTBot|ClaudeBot|anthropic-ai|Google-Extended|CCBot)) {
return 403;
}
# 屏蔽常见爬虫
if ($http_user_agent ~* (bingbot|YandexBot|DuckDuckBot|Yahoo|Sogou|Scrapy|curl|wget|python-requests|spider|crawler|libwww-perl|HTTrack|HttpClient|Go-http-client|axios|node-fetch)) {
return 403;
}
如果你需要加强版本:
# ============================
# 1. IP 限速# 限制每个 IP 的请求速率(每秒 5 次),# 限制每个 IP 的并发连接数(最多 20 个)
# ============================
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
# ============================
# 2. 防 CC# 防止同一 IP 在 1 秒内请求同一 URL 超过 3 次
# ============================
limit_req_zone $binary_remote_addr$uri zone=cc_limit:10m rate=3r/s;
server {
# AI 爬虫屏蔽
if ($http_user_agent ~* (GPTBot|ClaudeBot|anthropic-ai|Google-Extended|CCBot|Applebot)) {
return 403;
}
# 恶意爬虫屏蔽
if ($http_user_agent ~* (curl|wget|python|python-requests|Scrapy|spider|crawler|libwww-perl|HTTrack|HttpClient|Go-http-client|axios|node-fetch|Java|okhttp|php|ruby|perl)) {
return 403;
}
# 非浏览器 UA 屏蔽
if ($http_user_agent = "") { return 403; }
if ($http_user_agent !~* "(Mozilla|Chrome|Safari|Firefox|Edge)") { return 403; }
# IP 限速
limit_req zone=req_limit_per_ip burst=10 nodelay;
limit_conn conn_limit_per_ip 20;
# 防 CC
limit_req zone=cc_limit burst=5 nodelay;
}第一步:robots.txt 配置User-agent:GPTBotDisallow:/User-agent:ClaudeBotDisallow:/User-agent:anthropic...
起因是客户的网站在产品详情页有很多图片,比淘宝详情页还多。然后PC端和手机端又是独立分开的,单PC端或者...
给一个客户做的网站,详情页中七八十张图片。所以需要处理加载过慢的问题。现在使用懒加载的方式来处理。&l...
最近发现一些网站在复制别的文章的时候,远程本地化图片的时候不能本地化。下面来说一下如何处理这个问题:...