首页 最新 热门 推荐

  • 首页
  • 最新
  • 热门
  • 推荐

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

  • 25-04-24 12:01
  • 3371
  • 13702
blog.csdn.net

考虑到这些爬虫压根不遵守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

下面是爬虫列表:

  1. User–agent: AI2Bot
  2. User–agent: Ai2Bot–Dolma
  3. User–agent: Amazonbot
  4. User–agent: anthropic–ai
  5. User–agent: Applebot
  6. User–agent: Applebot–Extended
  7. User–agent: Bytespider
  8. #注意:Bytespider是字节跳动的爬虫,也用于头条搜索,请根据网站来自头条的流量决定是否要屏蔽
  9. User–agent: CCBot
  10. User–agent: ChatGPT–User
  11. #注意:ChatGPT-User是代理用户访问的爬虫,该爬虫不用于收集数据训练AI,请根据情况自行决定是否屏蔽
  12. User–agent: Claude–Web
  13. User–agent: ClaudeBot
  14. User–agent: cohere–ai
  15. User–agent: Diffbot
  16. User–agent: DuckAssistBot
  17. User–agent: FacebookBot
  18. User–agent: facebookexternalhit
  19. User–agent: FriendlyCrawler
  20. User–agent: Google–Extended
  21. User–agent: GoogleOther
  22. User–agent: GoogleOther–Image
  23. User–agent: GoogleOther–Video
  24. User–agent: GPTBot
  25. User–agent: iaskspider/2.0
  26. User–agent: ICC–Crawler
  27. User–agent: ImagesiftBot
  28. User–agent: img2dataset
  29. User–agent: ISSCyberRiskCrawler
  30. User–agent: Kangaroo Bot
  31. User–agent: Meta–ExternalAgent
  32. User–agent: Meta–ExternalFetcher
  33. User–agent: OAI–SearchBot
  34. User–agent: omgili
  35. User–agent: omgilibot
  36. User–agent: PerplexityBot
  37. User–agent: PetalBot
  38. User–agent: Scrapy
  39. User–agent: Sidetrade indexer bot
  40. User–agent: Timpibot
  41. User–agent: VelenPublicWebCrawler
  42. User–agent: Webzio–Extended
  43. 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 操作,则爬虫遵守协议的情况下它们不会再对其他内容进行抓爬,但如果不遵守协定那就会继续反复抓爬并给你的服务器造成压力。

注:本文转载自blog.csdn.net的bing0719的文章"https://blog.csdn.net/wang7396/article/details/146516349"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接
复制链接
相关推荐
发表评论
登录后才能发表评论和回复 注册

/ 登录

评论记录:

未查询到任何数据!
回复评论:

分类栏目

后端 (14832) 前端 (14280) 移动开发 (3760) 编程语言 (3851) Java (3904) Python (3298) 人工智能 (10119) AIGC (2810) 大数据 (3499) 数据库 (3945) 数据结构与算法 (3757) 音视频 (2669) 云原生 (3145) 云平台 (2965) 前沿技术 (2993) 开源 (2160) 小程序 (2860) 运维 (2533) 服务器 (2698) 操作系统 (2325) 硬件开发 (2492) 嵌入式 (2955) 微软技术 (2769) 软件工程 (2056) 测试 (2865) 网络空间安全 (2948) 网络与通信 (2797) 用户体验设计 (2592) 学习和成长 (2593) 搜索 (2744) 开发工具 (7108) 游戏 (2829) HarmonyOS (2935) 区块链 (2782) 数学 (3112) 3C硬件 (2759) 资讯 (2909) Android (4709) iOS (1850) 代码人生 (3043) 阅读 (2841)

热门文章

121
服务器
关于我们 隐私政策 免责声明 联系我们
Copyright © 2020-2024 蚁人论坛 (iYenn.com) All Rights Reserved.
Scroll to Top