{"id":19715918,"url":"https://github.com/logocomune/botdetector","last_synced_at":"2025-04-29T20:30:43.246Z","repository":{"id":57515966,"uuid":"245013391","full_name":"logocomune/botdetector","owner":"logocomune","description":"BotDetector is a golang library that detects Bot/Spider/Crawler from user agent","archived":false,"fork":false,"pushed_at":"2024-10-04T20:00:50.000Z","size":7043,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T19:03:48.652Z","etag":null,"topics":["botdetector","bots","crawler","go","golang","golang-library","spider","user-agent"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/logocomune.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-04T22:03:44.000Z","updated_at":"2025-03-18T12:04:42.000Z","dependencies_parsed_at":"2022-08-28T16:50:28.405Z","dependency_job_id":null,"html_url":"https://github.com/logocomune/botdetector","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logocomune%2Fbotdetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logocomune%2Fbotdetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logocomune%2Fbotdetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logocomune%2Fbotdetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/logocomune","download_url":"https://codeload.github.com/logocomune/botdetector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251578270,"owners_count":21612006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["botdetector","bots","crawler","go","golang","golang-library","spider","user-agent"],"created_at":"2024-11-11T22:39:45.539Z","updated_at":"2025-04-29T20:30:41.764Z","avatar_url":"https://github.com/logocomune.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BotDetector\n\n[![Build Status](https://app.travis-ci.com/logocomune/botdetector.svg?branch=master)](https://app.travis-ci.com/logocomune/botdetector)\n[![Go Report Card](https://goreportcard.com/badge/github.com/logocomune/botdetector)](https://goreportcard.com/report/github.com/logocomune/botdetector)\n[![codecov](https://codecov.io/gh/logocomune/botdetector/branch/master/graph/badge.svg)](https://codecov.io/gh/logocomune/botdetector)\n\nBotDetector is a Go library that detects bots, spiders, and crawlers from user agents.\n\n## Installation\n\n`go get -u github.com/logocomune/botdetector/v2`\n\n## Usage\n\n### Simple usage\n\n```go\n   userAgent := req.Header.Get(\"User-Agent\")\n\ndetector, _ := botdetector.New()\nisBot := detector.IsBot(userAgnet)\n\nif isBot {\nlog.Println(\"Bot, Spider or Crawler detected\")\n}\n\n```\n\n### Adding Custom Rules\n\nYou can add custom detection rules with the `WithRules` method. For example:\n\n```go\nuserAgent := req.Header.Get(\"User-Agent\")\n\ndetector, _ := botdetector.New(WithRules([]string{\"my rule\", \"^test\"}))\nisBot := detector.IsBot(userAgent)\n\nif isBot {\nlog.Println(\"Bot, Spider or Crawler detected\")\n}\n\n```\n\nCustom Rule Patterns:\n\n| pattern | description                                               |\n|---------|-----------------------------------------------------------|\n| \"...\"   | Checks if the string contains the specified pattern.      |\n| \"^...\"  | Checks if the string starts with the specified pattern.   |\n| \"...$\"  | Checks if the string ends with the specified pattern.     |\n| \"^...$\" | Checks if the string strictly matches the entire pattern. |\n\nIn this example, the custom rules \"my rule\" and \"^test\" are added to the existing detection rules.\n\n### Adding Cache\nYou can add a lru cache rules with the `WithCache` method. For example:\n\n```go\nuserAgent := req.Header.Get(\"User-Agent\")\n\ndetector, _ := botdetector.New(WithCache(1000))\nisBot := detector.IsBot(userAgent)\n\nif isBot {\nlog.Println(\"Bot, Spider or Crawler detected\")\n}\n\n```\n\n\n\n### Example\n\n[Simple example](_example/main.go)\n\n## Inspiration\n\nBotSeeker is inspired by [CrawlerDetect](https://github.com/JayBizzle/Crawler-Detect), an awesome PHP project.\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogocomune%2Fbotdetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flogocomune%2Fbotdetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogocomune%2Fbotdetector/lists"}