UserAgentUtils 始终提供空浏览器版本
我正在使用 UserAgentUtils Java 库在 PDI 转换期间从浏览器的用户代理字符串中提取用户代理详细信息,但无论我做什么,在解析用户代理字符串后我总是从库中返回空版本,即使在我可以清楚地看到字符串中的版本。例如:
String userAgentString = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/533.3 (KHTML, like Gecko) capybara-webkit Safari/533.3"
UserAgent userAgent = new UserAgent(userAgentString)
userAgent.getBrowserVersion() //always comes back null
两个问题。我没有做正确的事情来从 UserAgentUtils 取回数据(这似乎不是一个错误,因为他们的错误跟踪系统中没有与此相关的问题历史记录)?
或者,是否有另一个 Java 或 JavaScript 库可以用来从用户代理字符串中提取组件信息?两者都可以,因为我可以同样轻松地在该代码所在的 PDI 作业中使用其中任何一个。
I'm using the UserAgentUtils Java library to extract user agent details from the user agent string of browsers during a PDI transform, but no matter what I do I always get back a null version from the library after parsing the user agent string, even when I can clearly see the version in the string. For example:
String userAgentString = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/533.3 (KHTML, like Gecko) capybara-webkit Safari/533.3"
UserAgent userAgent = new UserAgent(userAgentString)
userAgent.getBrowserVersion() //always comes back null
Two questions. What am I not doing right to get back the data from UserAgentUtils (it doesn't seem to be a bug because there's no history of issues related to this in their bug tracking system)?
Alternatively, is there another Java or JavaScript library I could use to extract the component information from user agent strings? Either one is okay, since I can equally easily use either in the PDI job where this code lives.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试为 jetty http 客户端请求设置 http 代理值?
我在我的用户定义的java类上执行此操作:
现在来自kettle的所有http请求都将发送带有此信息的用户代理标头
are you trying to set the http agent value for jetty http client requests?
i do this on my user defined java class:
now all your http requests from kettle will send user agent header with this info