Files
jiang13-forum/services/crawler.go
freefire 9fe299a45f refactor: Gitea 式目录改组,移除本分支 SPA 与杂项产物
将 model/service/handler/middleware 迁至 models/services/routers/api/modules/auth,并删除 frontend、embed_static、scripts 及误入库缓存/二进制。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 03:54:56 +08:00

56 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package service
import "strings"
// 常见搜索引擎 / 社交预览 / SEO 工具的 User-Agent 片段(小写匹配)
var seoCrawlerTokens = []string{
"googlebot",
"google-inspectiontool",
"bingbot",
"baiduspider",
"yandexbot",
"duckduckbot",
"slurp", // Yahoo
"sogou",
"bytespider",
"petalbot",
"applebot",
"facebookexternalhit",
"facebot",
"twitterbot",
"linkedinbot",
"discordbot",
"telegrambot",
"slackbot",
"whatsapp",
"preview", // 部分通用预览 UA
"embedly",
"quora link preview",
"pinterest",
"vkshare",
"w3c_validator",
"ahrefsbot",
"semrushbot",
"dotbot",
"mj12bot",
"gptbot",
"claudebot",
"anthropic-ai",
"chatgpt-user",
"oai-searchbot",
}
// IsSEOCrawler 是否为需要服务端 HTML 的爬虫 / 预览 bot动态渲染
func IsSEOCrawler(userAgent string) bool {
ua := strings.ToLower(strings.TrimSpace(userAgent))
if ua == "" {
return false
}
for _, token := range seoCrawlerTokens {
if strings.Contains(ua, token) {
return true
}
}
return false
}