云计算百科
云计算领域专业知识百科平台

nginx屏蔽AI爬虫,节省不必要的服务器cpu和网络开支(GPTBot,meta-externalagent,Amazonbot)

考虑到这些爬虫压根不遵守robots规则,所以直接在nginx服务器里面拦截最有效,大家可以将以下代码放在nginx网站配置文件里,放在

server里面就行了。以下列举了一部分爬虫,后面如果有更新,最新的代码会在该站更新nginx屏蔽AI爬虫,节省不必要的服务器cpu和网络开支(GPTBot,meta-externalagent,Amazonbot) – Bcoder资源网

if ($http_user_agent ~* "SemrushBot/7~bl|YandexBot|Amazonbot/0.1|GPTBot/1.2|GPTBot|Bytespider|meta-externalagent|Amazonbot|GPTBot|Meta-ExternalAgent|FeedDemon|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|^$" ) {

     return 301 https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=q.wpcoder.cn;

}

长久以来活跃在互联网上的爬虫都非常多,这些爬虫通常没有自己的独立名称,都是伪装成各种模仿用户的 UserAgent 进行抓爬。

现在更多爬虫是为了抓取数据用于训练 AI 模型,至少规模较大的 AI 公司会公布自己的爬虫名称,网站管理员可以屏蔽这些爬虫避免数据被抓取。

为什么要屏蔽 AI 爬虫:

这些爬虫的主要目的就是抓取你的网站内容拿去训练人工智能模型,这几乎不会给你的网站带来任何流量或其他正面反馈,因此直接屏蔽并没有什么大不了的。

当然正如 OpenAI 所说,允许 AI 爬虫抓取数据用于训练人工智能模型能够早日实现 AGI,为了这个宏大的理想你是否愿意被抓取呢?反正大多数大型出版商 (例如新闻网站) 都是不允许抓取的。

Ai Robots 开源项目:

该项目收集了众多已知的 AI 公司爬虫和少数不友好的爬虫,各位站长可以放心屏蔽,屏蔽后不影响网站的正常运行和继续获取来自主要搜索引擎的流量。

当然如果你不放心的话也可以将部分爬虫注释掉允许其继续抓取内容,如果你想了解每个爬虫的详细说明,请直接谷歌搜索爬虫名称,可以找到开发商的说明。

项目地址:https://github.com/ai-robots-txt/ai.robots.txt

下面是爬虫列表:

  • User–agent: AI2Bot
  • User–agent: Ai2Bot–Dolma
  • User–agent: Amazonbot
  • User–agent: anthropic–ai
  • User–agent: Applebot
  • User–agent: Applebot–Extended
  • User–agent: Bytespider
  • #注意:Bytespider是字节跳动的爬虫,也用于头条搜索,请根据网站来自头条的流量决定是否要屏蔽
  • User–agent: CCBot
  • User–agent: ChatGPT–User
  • #注意:ChatGPT-User是代理用户访问的爬虫,该爬虫不用于收集数据训练AI,请根据情况自行决定是否屏蔽
  • User–agent: Claude–Web
  • User–agent: ClaudeBot
  • User–agent: cohere–ai
  • User–agent: Diffbot
  • User–agent: DuckAssistBot
  • User–agent: FacebookBot
  • User–agent: facebookexternalhit
  • User–agent: FriendlyCrawler
  • User–agent: Google–Extended
  • User–agent: GoogleOther
  • User–agent: GoogleOther–Image
  • User–agent: GoogleOther–Video
  • User–agent: GPTBot
  • User–agent: iaskspider/2.0
  • User–agent: ICC–Crawler
  • User–agent: ImagesiftBot
  • User–agent: img2dataset
  • User–agent: ISSCyberRiskCrawler
  • User–agent: Kangaroo Bot
  • User–agent: Meta–ExternalAgent
  • User–agent: Meta–ExternalFetcher
  • User–agent: OAI–SearchBot
  • User–agent: omgili
  • User–agent: omgilibot
  • User–agent: PerplexityBot
  • User–agent: PetalBot
  • User–agent: Scrapy
  • User–agent: Sidetrade indexer bot
  • User–agent: Timpibot
  • User–agent: VelenPublicWebCrawler
  • User–agent: Webzio–Extended
  • User–agent: YouBot
  • robots.txt 示例:

    User-agent: *
    Allow: /wp-*/uploads/*
    Allow: /wp-*/themes/*
    Allow: /archives/user/1
    Disallow: /trackback
    Disallow: /wp-*
    Disallow: /\\?p=*
    Disallow: /?p=*
    Disallow: /?s=*
    Disallow: /*/attachment/*
    Disallow: /?post_type=post&s=*
    Disallow: /*?post_type=post
    Disallow: /*?post_type=download
    Disallow: /*?post_type=product
    Disallow: /*?post_type=video
    Disallow: /*?post_type=moment
    Disallow: /*?post_type=topic
    Disallow: /archives/user/*
    Sitemap: https://www.landiannews.com/sitemap.xml
    User-agent: MJ12bot
    Disallow: /
    User-agent: istellabot
    Disallow: /
    User-agent: SemrushBot
    Disallow: /
    User-agent: SemrushBot-SA
    Disallow: /
    User-agent: Dotbot
    Disallow: /
    User-agent: CriteoBot/0.1
    Disallow: /
    User-agent: ClaudeBot
    Disallow: /
    User-agent: AI2Bot
    Disallow: /
    User-agent: Ai2Bot-Dolma
    Disallow: /
    User-agent: Amazonbot
    Disallow: /
    User-agent: anthropic-ai
    Disallow: /
    User-agent: Applebot
    Disallow: /
    User-agent: Applebot-Extended
    Disallow: /
    #User-agent: Bytespider
    #Disallow: /
    User-agent: CCBot
    Disallow: /
    #User-agent: ChatGPT-User
    #Disallow: /
    User-agent: Claude-Web
    Disallow: /
    User-agent: ClaudeBot
    Disallow: /
    User-agent: cohere-ai
    Disallow: /
    User-agent: Diffbot
    Disallow: /
    User-agent: DuckAssistBot
    Disallow: /
    User-agent: FacebookBot
    Disallow: /
    User-agent: facebookexternalhit
    Disallow: /
    User-agent: FriendlyCrawler
    Disallow: /
    User-agent: Google-Extended
    Disallow: /
    User-agent: GoogleOther
    Disallow: /
    User-agent: GoogleOther-Image
    Disallow: /
    User-agent: GoogleOther-Video
    Disallow: /
    User-agent: GPTBot
    Disallow: /
    User-agent: iaskspider/2.0
    Disallow: /
    User-agent: ICC-Crawler
    Disallow: /
    User-agent: ImagesiftBot
    Disallow: /
    User-agent: img2dataset
    Disallow: /
    User-agent: ISSCyberRiskCrawler
    Disallow: /
    User-agent: Kangaroo Bot
    Disallow: /
    User-agent: Meta-ExternalAgent
    Disallow: /
    User-agent: Meta-ExternalFetcher
    Disallow: /
    #User-agent: OAI-SearchBot
    #Disallow: /
    User-agent: omgili
    Disallow: /
    User-agent: omgilibot
    Disallow: /
    User-agent: PerplexityBot
    Disallow: /
    User-agent: PetalBot
    Disallow: /
    User-agent: Scrapy
    Disallow: /
    User-agent: Sidetrade indexer bot
    Disallow: /
    User-agent: Timpibot
    Disallow: /
    User-agent: VelenPublicWebCrawler
    Disallow: /
    User-agent: Webzio-Extended
    Disallow: /
    User-agent: YouBot
    Disallow: /

    需要提醒的是 robots.txt 文件属于君子协定,此前 PerplexityBot 爬虫就被发现即便屏蔽也会继续抓取内容,所以仅仅依靠君子协定显然是不够的。

    你甚至可以在 Nginx 服务器中直接将这些爬虫名称加入黑名单,在它们尝试抓爬时直接返回 HTTP 444 丢弃连接,这样也可以阻止内容被抓取。

    但请注意:如果你在服务器上执行屏蔽操作那 robots.txt 文件就无效了,因为爬虫刚抵达服务器就直接被拦截,因此它们也无法先检查 robots.txt 文件是否允许抓取,在这种情况下这些爬虫可能会反复、高频抓取然后被丢弃连接。

    如果仅通过 robots.txt 操作,则爬虫遵守协议的情况下它们不会再对其他内容进行抓爬,但如果不遵守协定那就会继续反复抓爬并给你的服务器造成压力。

    赞(0)
    未经允许不得转载:网硕互联帮助中心 » nginx屏蔽AI爬虫,节省不必要的服务器cpu和网络开支(GPTBot,meta-externalagent,Amazonbot)
    分享到: 更多 (0)

    评论 抢沙发

    评论前必须登录!