移除旧版 HTML 模板与兼容层,并完善私信、举报、媒体存储与 SEO。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
55
service/crawler.go
Normal file
55
service/crawler.go
Normal file
@@ -0,0 +1,55 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user