如何确定HTTP请求是来自浏览器还是其他类似Web服务? [英] How do I determine if a HTTP request came from a browser or something else like a web service?

查看:326
本文介绍了如何确定HTTP请求是来自浏览器还是其他类似Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定HTTP请求是来自浏览器还是其他类似Web服务?

How do I determine if a HTTP request came from a browser or something else like a web service?

我知道有一个用户代理,但是这个似乎主要针对Web浏览器。例如,我知道该请求来自谷歌地图或youtube。该请求来自一个系留设备。

I am aware that there is a User Agent, but this seems mainly for web browsers. For instance I do I know the request came from a google maps or youtube. The request are coming off a tethered device.

如果他们有不同的用户代理,我可以得到一个例子。

If they have a different User Agent, can I get an example.

谢谢。

推荐答案

绝对无法确定是否有来自浏览器或其他内容的请求HTTP请求。

There is absolutely no way to know with certainty if a request came from a browser or something else making an HTTP request.

HTTP协议允许客户端任意设置用户代理。

The HTTP protocol allows for the client to set the User Agent arbitrarily.

一个可以试图确定另一端的东西是否是浏览器,例如通过执行JavaScript并测量结果。但是,有些机器人可以执行JavaScript,并非所有浏览器都执行JavaScript,因此测试类型永远不会完美。

One can attempt to determine if the thing on the other end is a browser e.g. by executing JavaScript and measuring the outcome. However, some bots can execute JavaScript, and not all browsers execute JavaScript so that type of test can never be perfect.

表现良好的机器人(如常见的搜索引擎)蜘蛛)将使用特定于他们的用户代理来识别自己。这里有一个非常全面的用户代理列表:

Well-behaved "bots" (like common search engine spiders) will identify themselves using a User Agent specific to them. There's a pretty comprehensive list of user agents here:

http ://www.user-agents.org/

http://www.botsvsbrowsers.com/

这篇关于如何确定HTTP请求是来自浏览器还是其他类似Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆