| | |
| | | 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; |
| | |
| | | |
| | | private Capabilities capabilities = null; |
| | | private UserAgentParser parser = null; |
| | | |
| | | // 搜索地区的本地对象(读取本地xdb数据库),2024-04-02 |
| | | private Searcher searcher = null; |
| | | |
| | | public BrowserCapWebAgentService(){ |
| | | try { |
| | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("创建浏览器解析对象错误:" + e.getMessage(), e); |
| | | } |
| | | |
| | | // this.searcher = Searcher.newWithFileOnly(); |
| | | // ClassPathResource resource = new ClassPathResource(); |
| | | // resource.getFile(); |
| | | // RandomAccessFile randomAccessFile = new RandomAccessFile(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return webUserAgent; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置是否加载ip对应的区域地质,默认:false不加载,因为需要连外网查找。 |
| | | * @param loadLocation |
| | |
| | | this.loadLocation = loadLocation; |
| | | } |
| | | |
| | | /** |
| | | * 设置:ip2region数据库文件路径,如: |
| | | * @param xdbPath |
| | | */ |
| | | public void setXdbPath(String xdbPath) { |
| | | this.xdbPath = xdbPath; |
| | | } |
| | | |
| | | private String xdbPath; |
| | | private boolean loadLocation = false; |
| | | } |