Syntactic patterns of HTTP user-agents used by bots / robots / crawlers / scrapers / spiders. pull-request welcome :star:
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 8 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 4 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 7 年前 | ||
| 1 年前 | ||
| 8 年前 | ||
| 2 年前 | ||
| 1 年前 |
爬虫用户代理列表
此仓库包含了一个单一的 JSON 文件,其中列出了机器人、爬虫和蜘蛛使用的 HTTP 用户代理。
- NPM 包:https://www.npmjs.com/package/crawler-user-agents
- Go 包:https://pkg.go.dev/github.com/monperrus/crawler-user-agents
- PyPi 包:https://pypi.org/project/crawler-user-agents/
每个 pattern 是一个正则表达式。它应该能够与您喜欢的正则表达式库即开即用。
如果您在商业产品中使用此项目,请赞助它。
安装
直接下载
直接从此仓库下载 crawler-user-agents.json 文件。
JavaScript
crawler-user-agents 已部署在 npmjs.com:https://www.npmjs.com/package/crawler-user-agents
若要使用 npm 或 yarn 进行安装:
npm install --save crawler-user-agents
# OR
yarn add crawler-user-agents
在 Node.js 中,您可以使用 require 方法导入包以获取爬虫用户代理的数组。
const crawlers = require('crawler-user-agents');
console.log(crawlers);
Python
使用 pip install crawler-user-agents 进行安装。
然后:
import crawleruseragents
if crawleruseragents.is_crawler("Googlebot/"):
# do something
或者:
import crawleruseragents
indices = crawleruseragents.matching_crawlers("bingbot/2.0")
print("crawlers' indices:", indices)
print(
"crawler's URL:",
crawleruseragents.CRAWLER_USER_AGENTS_DATA[indices[0]]["url"]
)
请注意,matching_crawlers 的速度远低于 is_crawler,如果提供的 User-Agent 确实与任何爬虫相匹配。
Go
在 Go 语言中,请使用 这个包,
它提供了全局变量 Crawlers(它与 crawler-user-agents.json 同步),
以及 IsCrawler 和 MatchingCrawlers 函数。
Go 程序示例:
package main
import (
"fmt"
"github.com/monperrus/crawler-user-agents"
)
func main() {
userAgent := "Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)"
isCrawler := agents.IsCrawler(userAgent)
fmt.Println("isCrawler:", isCrawler)
indices := agents.MatchingCrawlers(userAgent)
fmt.Println("crawlers' indices:", indices)
fmt.Println("crawler's URL:", agents.Crawlers[indices[0]].URL)
}
输出:
isCrawler: true
crawlers' indices: [237]
crawler' URL: https://discordapp.com
贡献指南
我非常欢迎通过提交 PR(拉取请求)来增加内容。
PR 应该满足以下要求:
- 仅包含一项新增内容
- 指定一个具有辨识度的相关语法片段(例如 "totobot",而非 "Mozilla/5 totobot v20131212.alpha1")
- 包含模式(通用正则表达式)、发现日期(年/月/日)以及机器人的官方 URL
- 确保生成的 JSON 文件格式正确(别忘了在项目之间添加逗号)
例如:
{
"pattern": "rogerbot",
"addition_date": "2014/02/28",
"url": "http://moz.com/help/pro/what-is-rogerbot-",
"instances" : ["rogerbot/2.3 example UA"]
}
许可
本列表遵循 MIT 许可。2016年11月7日之前的版本遵循 CC-SA 许可。
相关工作
有一些封装库利用这些数据来检测机器人:
- Voight-Kampff(Ruby)
- isbot(Ruby)
- crawlers(Clojure)
- isBot(Node.JS)
其他可用于发现机器人、爬虫和蜘蛛的系统,您可以考虑的有:
- Crawler-Detect(PHP)
- BrowserDetector(PHP)
- browscap(JSON 文件)