Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

A small, fast and dependency less Java library to detect and verify bots and crawlers on the basis of user-agents and IP addresses. The authenticity of a bot can be verified with reverse dns lookups.

License

Notifications You must be signed in to change notification settings

UeliKurmann/bot-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bot-detector

Maven Dependency

<dependency>
  <groupId>ch.javacamp.bot-detector</groupId>
  <artifactId>bot-detector</artifactId>
  <version>1.0.1</version>
</dependency>

Quickstart

Detect a bot without verification

package ch.javacamp.botdetector.examples;

import ch.javacamp.botdetector.Assessment;
import ch.javacamp.botdetector.Bots;
import ch.javacamp.botdetector.RequestDescriptor;

public class DetectionExample {

    public static void main(String[] args) {
        RequestDescriptor descriptor = RequestDescriptor.create("66.249.79.195", "... Googlebot/2.1; ...");
        Assessment actual = Bots.detector().detect(descriptor);
        if(actual.isBot()){
            System.out.println("a bot...");
        }
    }
}

Detect a bot with identification and verification

package ch.javacamp.botdetector.examples;

import ch.javacamp.botdetector.BotDescription;
import ch.javacamp.botdetector.Bots;
import ch.javacamp.botdetector.RequestDescriptor;

import java.util.Optional;

public class DetectionIdentificationExample {

    public static void main(String[] args) {
        RequestDescriptor descriptor = RequestDescriptor.create("66.249.79.195", "... Googlebot/2.1; ...");
        Optional<BotDescription> actual = Bots.detector().detect(descriptor).identifyVerified();

        actual.ifPresent(a -> System.out.println(a.name()));
        actual.ifPresent(a -> System.out.println(a.verification()));
    }
}

List of Verification Rules

The available verification rules can be seen here: Link

About

A small, fast and dependency less Java library to detect and verify bots and crawlers on the basis of user-agents and IP addresses. The authenticity of a bot can be verified with reverse dns lookups.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages