user-agent

Rails Browser Detection Methods

霸气de小男生 提交于 2019-11-27 04:09:58
Hey Everyone, I was wondering what methods are standard within the industry to do browser detection in Rails? Is there a gem, library or sample code somewhere that can help determine the browser and apply a class or id to the body element of the (X)HTML? Thanks, I'm just wondering what everyone uses and whether there is accepted method of doing this? I know that we can get the user.agent and parse that string, but I'm not sure if that is that is an acceptable way to do browser detection. Also, I'm not trying to debate feature detection here, I've read multiple answers for that on StackOverflow

Mobile detection [closed]

99封情书 提交于 2019-11-27 03:57:37
Is there a way to detect mobile devices using Javascript? Also, I researched that there are such an XML which contains user-agents that could help to identify the mobile handsets. You probably have a normal site and you want to redirect to a mobile site if certain conditions are met, like the screen is very small, or the content is zoomed out to fit on a large "virtual" screen in a small physical space. So, why not check for those conditions instead of testing a zillion UA strings. Try something like this: For the UA to report the screen's physical pixel size, this tag must be present in the

How to detect “Google Chrome” as the user-agent using PHP?

你离开我真会死。 提交于 2019-11-27 03:48:39
问题 I'm interested to know whether the user-agent is "Chrome" at the server end using PHP. Is there a reliable regular expression for parsing out the user-agent string from the request header? 回答1: At this point, too many browsers are pretending to be Chrome in order to ride on its popularity as well as combating abuse of browser detection for a simple match for "Chrome" to be effective anymore. I would recommend feature detection going forward, but Chrome (and WebKit/Blink in general) is

Changing User Agent in Python 3 for urrlib.request.urlopen

左心房为你撑大大i 提交于 2019-11-27 03:42:49
I want to open a url using urllib.request.urlopen('someurl') : with urllib.request.urlopen('someurl') as url: b = url.read() I keep getting the following error: urllib.error.HTTPError: HTTP Error 403: Forbidden I understand the error to be due to the site not letting python access it, to stop bots wasting their network resources- which is understandable. I went searching and found that you need to change the user agent for urllib. However all the guides and solutions I have found for this issue as to how to change the user agent have been with urllib2, and I am using python 3 so all the

Redirect mobile devices to alternate version of my site

柔情痞子 提交于 2019-11-27 03:35:54
We've got an alternate version of out website ready for mobile devices. The content we serve is different and it works well. What is the best way to detect which version to serve. We don't have a list of all mobile devices so to use the user-agent header is tricky as we may miss something. We thought about useing device screen width - but what happens if the mobile device doesnt support javascript. How do we sniff this ? You could use a device description database (such as WURFL ) which will recognise the client device from the request headers. You can then query that database to decide if the

What is the iOS 5.0 user agent string?

喜你入骨 提交于 2019-11-27 03:08:21
What is the iOS 5.0 user agent string? Here is the iOS 4.0 user agent: What is the iPhone 4 user-agent? iPhone: Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3 iPad: Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3 This site seems to keep a complete list that's still maintained iPhone, iPod Touch, and iPad from iOS 2.0 - 5.1.1 (to date). You do need to assemble the full user-agent string out of the information listed in the page's

Distinguish between iPhone web browser and iPhone app user agent

*爱你&永不变心* 提交于 2019-11-27 02:12:38
问题 What is the best way to distinguish on a server between a request that came from an iPhone through the web browser vs through an iphone with an app written in objective c? What differences do I look for in the user agent string? 回答1: I believe user agents from the Safari app start with "Mozilla", while user agents from apps start with the name of the app. 回答2: It seems that iPhone Apps using the UIWebKit HTTP request component have user agent string like the following Mozilla/5.0 (iPhone; U;

Change Phonegap User Agent

若如初见. 提交于 2019-11-27 01:29:13
问题 My Phonegap application is allowed to browse to some external sites that also use the Phonegap API. Currently I am conditionally including the Phonegap javascript based on what platform you are on (Android, iOS, etc). However, I can't tell the difference between Phonegap applications and the regular browser on a mobile device. Is there a way to change the user agent in my Phonegap app to give my server a hint about this? Most interested in the iOS solution to this. 回答1: This answer to a

Get Android OS version from user-agent

ⅰ亾dé卋堺 提交于 2019-11-27 01:08:08
问题 I've been trying to find a parser or regex that will give me the Android OS version from a user agent string. E.g. Mozilla/5.0 (Linux; U; Android 2.2.1; fr-fr; Desire HD Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Will return: 2.2.1 Can anyone help? 回答1: This regular expression is a bit more "future proof" than mathepic's answer: Android (\d+(?:\.\d+)+); It allows for multiple digits in each place as well as additional periods in the version number.

Fetch a Wikipedia article with Python

不打扰是莪最后的温柔 提交于 2019-11-27 00:50:56
I try to fetch a Wikipedia article with Python's urllib: f = urllib.urlopen("http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes") s = f.read() f.close() However instead of the html page I get the following response: Error - Wikimedia Foundation: Request: GET http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes, from 192.35.17.11 via knsq1.knams.wikimedia.org (squid/2.6.STABLE21) to () Error: ERR_ACCESS_DENIED, errno [No Error] at Tue, 23 Sep 2008 09:09:08 GMT Wikipedia seems to block request which are not from a standard browser. Anybody know how to work