shikeying
2024-04-03 b77abcbc0f17070a2a970e0c4aa5837e90f28e1f
walker-web/src/main/java/com/walker/web/agent/BrowserCapWebAgentService.java
@@ -3,6 +3,7 @@
import com.walker.web.WebAgentService;
import com.walker.web.WebUserAgent;
import com.walker.web.util.IpUtils;
import org.lionsoul.ip2region.xdb.Searcher;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
@@ -15,6 +16,9 @@
    private Capabilities capabilities = null;
    private UserAgentParser parser = null;
    // 搜索地区的本地对象(读取本地xdb数据库),2024-04-02
    private Searcher searcher = null;
    public BrowserCapWebAgentService(){
        try {
@@ -30,6 +34,11 @@
        } catch (Exception e) {
            throw new RuntimeException("创建浏览器解析对象错误:" + e.getMessage(), e);
        }
//        this.searcher = Searcher.newWithFileOnly();
//        ClassPathResource resource = new ClassPathResource();
//        resource.getFile();
//        RandomAccessFile randomAccessFile = new RandomAccessFile();
    }
    @Override
@@ -59,6 +68,7 @@
        return webUserAgent;
    }
    /**
     * 设置是否加载ip对应的区域地质,默认:false不加载,因为需要连外网查找。
     * @param loadLocation
@@ -68,5 +78,14 @@
        this.loadLocation = loadLocation;
    }
    /**
     * 设置:ip2region数据库文件路径,如:
     * @param xdbPath
     */
    public void setXdbPath(String xdbPath) {
        this.xdbPath = xdbPath;
    }
    private String xdbPath;
    private boolean loadLocation = false;
}