user-agent

What's the best way to detect a browser with php?

核能气质少年 提交于 2019-12-20 02:28:11
问题 Could anyone tell me the best way to detect a browser using php? IE 6 and 7 are terrible when it comes to achieving full browser compatibility with CSS so my site isn't going to support and version of IE that's older than 8. I'm current using $_SERVER['HTTP_USER_AGENT'] to detect the browser but I've been told that that isn't a good way to do it since browsers can lie and send any user agent info that they want. So, does anyone know of a sure fire way to detect the type of browser that the

SQL performance searching for long strings

淺唱寂寞╮ 提交于 2019-12-19 19:42:02
问题 I need to store user agent strings in a database for tracking and comparing customer behavior and sales performance between different browsers. A pretty plain user agent string is around 100 characters long. It was decided to use a varchar(1024) for holding the useragent data in the database. (I know this is overkill, but that's the idea; it's supposed to accommodate useragent data for years to come and some devices, toolbars, applications are already pushing 500 characters in length.) The

How can I set User-Agent and Referer headers when using ClientWebSocket in .net 4.5?

笑着哭i 提交于 2019-12-19 08:50:26
问题 The obvious answer of using ClientWebSocket.SetHeader throws an exception because it's a protected header: System.ArgumentException occurred Message=The 'User-Agent' header must be modified using the appropriate property or method. Parameter name: name ParamName=name StackTrace: at System.Net.WebHeaderCollection.ThrowOnRestrictedHeader(String headerName) The exception string suggests using a property/method on the ClientWebSocket itself but I can't find any such property/method. It seems this

Is there a quintessential mobile User-Agent regexp pattern?

假如想象 提交于 2019-12-19 06:30:10
问题 There are endless examples in the tubes of regexp patterns designed to detect mobile User-Agents, even quite a few in answers herein. Do you know of one that is perhaps most widely used and supported (updated, in perhaps a Git repository)? There tends to be a It's dangerous to go alone! Take this. version of everything, eventually (e.g. browser reset CSS by Eric Meyer, et al), so perhaps there is for this as well. 回答1: detectmobilebrowsers.com provides this solution (for JS): (function(a,b)

Detecting Microsoft's edge or spartan with javascript

情到浓时终转凉″ 提交于 2019-12-18 18:46:46
问题 Is the user agent for Edge or Spartan browsers known already? Can anyone tell me how to detect this browser and diferentiate it from IE in advance of its release? 回答1: A simple google search found me the answer you are looking for: http://forum.piwik.org/read.php?3,125732 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0 Therefore you should match: "Edge\/\d+" 回答2: According to this answer: // Internet Explorer 6-11

postman指定User-Agent的header无效

℡╲_俬逩灬. 提交于 2019-12-18 14:53:05
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 今天调试某个接口,server根据User-Agent不同返回不同内容,用postman调试,结果指定了User-Agent的header,但是一直不变化,最后用curl发送,可以了。这应该是postman的bug吧。 用modify headers插件可以。 来源: oschina 链接: https://my.oschina.net/u/106378/blog/517262

PHP Undefined index: HTTP_USER_AGENT

送分小仙女□ 提交于 2019-12-18 14:12:32
问题 The following code validates the user agent accessing the site however I am getting the error. What do I need to update to accommodate scenarios where there is no user agent being set? ERROR PHP Notice: Undefined index: HTTP_USER_AGENT in Utils.php on line 7 CODE public static function detectBrowser() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); if (preg_match('/opera/', $userAgent)) { $name = 'opera'; } elseif (preg_match('/webkit/', $userAgent)) { $name = 'safari'; } elseif (preg

How to set a custom user agent in ruby

心已入冬 提交于 2019-12-18 12:51:09
问题 I've a task to test different user agents on a URL through automation. I'm using ruby to code, and I've been trying to set an user agent using the following method, but it doesn't seem to recognize the user agent. @http = Net::HTTP.new(URL) response = @http.request_get(URL, {'User-Agent' => useragent}) Is there any other way to do this, or what am I doing wrong? 回答1: http = Net::HTTP.new("your.site.com", 80) req = Net::HTTP::Get.new("/path/to/the/page.html", {'User-Agent' => 'your_agent'})

What is the user agent string for surface rt?

青春壹個敷衍的年華 提交于 2019-12-18 11:43:19
问题 I'm trying to determine the user agent string for surface RT for testing purposes. 回答1: Just do some Google'ing and you will find your answer. Internet Explorer 10 User-agent string Internet Explorer 10 on Windows RT: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0) Update after comment below The link above also states: Identifying touch-enabled systems Internet Explorer 10 introduces the "Touch" UA string token. If this token is present at the end of the UA string, the

Why does Internet Explorer (9) report “Mozilla” in UserAgent?

耗尽温柔 提交于 2019-12-18 10:58:14
问题 Why does Internet Explorer has Mozilla in UserAgent? In Firefox it's stating: Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1 In Interner Explorer it's stating: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET4.0E; .NET4.0C) In some blogs/forums it's mentioned, that it is due to some historical reasons, but what's the reason? It would be very helpful