user-agent

How to detect Browser type in Django?

寵の児 提交于 2019-11-29 21:18:31
How can i detect which browser type the client is using. I have a problem where i have to ask people to use different browser (Firefox) instead of IE. How can i get this information. I know http request has this information (Header). How will i get the navigator.appName from the view.py in the Django framework ? You can extract that information from the request object like so: request.META['HTTP_USER_AGENT'] Ahmad Awais There are multiple ways of getting that done. The easiest way is what @digitaldreamer recommended. That is you can make a meta request for HTTP_USER_AGENT . request.META['HTTP

Detect mobile browser (not just iPhone) in python view

*爱你&永不变心* 提交于 2019-11-29 20:56:17
I have a web application written in Django that has one specific page I'd like to implement a mobile version of the template (and slightly different logic) for. I'd like to be able to implement it ala this sudo code: def(myView) do some stuff if user-is-on-a-mobile-device: do some stuff return (my mobile template) else: do some stuff return (my normal template) I don't have a huge amount of time and I'm pretty early on in my coding learning curve :) - I found what looks to be a very powerful pluggable app called bloom for getting mobile device capablities - http://code.google.com/p/django

Sites not accepting wget user agent header

天涯浪子 提交于 2019-11-29 19:12:40
When I run this command: wget --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" http://yahoo.com ...I get this result (with nothing else in the file): <!-- hw147.fp.gq1.yahoo.com uncompressed/chunked Wed Jun 19 03:42:44 UTC 2013 --> But when I run wget http://yahoo.com with no --user-agent option, I get the full page. The user agent is the same header that my current browser sends. Why does this happen? Is there a way to make sure the user agent doesn't get blocked when using wget? It seems Yahoo server does some heuristic based on User-Agent in a

How to set User-Agent in WebClient

烂漫一生 提交于 2019-11-29 16:43:06
I used the code below to open a stream request to a youtube video, but it always return an exception "The remote server returned an error: NotFound". Then I tried to use Fiddler to detect the problem, and I saw that the WebClient auto set User-Agent field to NativeHost, not my User-Agent as below. My code to send a request to youtube: private static Task<string> HttpGet(string uri) { var task = new TaskCompletionSource<string>(); var web = new WebClient(); web.OpenReadCompleted += (sender, args) => { if (args.Cancelled) task.SetCanceled(); else if (args.Error != null) task.SetException(args

How does HTTP_USER_AGENT work? [duplicate]

我是研究僧i 提交于 2019-11-29 16:16:39
问题 Possible Duplicate: Why navigator.appCodeName returning Mozilla? When I get the PHP server variable HTTP_USER_AGENT with this code: <?php $useragent = $_SERVER ['HTTP_USER_AGENT']; echo "<b>Your User Agent is</b>: " . $useragent; ?> I get this in Google chrome: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4 This in firefox: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0 And this in IE: Mozilla/5.0 (compatible; MSIE 9.0;

How to set navigator userAgent?

∥☆過路亽.° 提交于 2019-11-29 15:38:07
Ok this is an edge case I have managed to land in. I am testing my app on the new Tizen OS. My JS code has thousands of navigator checks. Something like: navigator.userAgent.toLocaleLowerCase().indexOf("android") || navigator.userAgent.toLocaleLowerCase().indexOf("iPad") Now Tizen OS's userAgent on my test device does not have either of those strings. A lot of my css and JS is breaking as a result. I am in the POC mode right now and do not want to spend time in adding an additional check to all those conditions. Is there a way to programmatically set userAgent ? Something along the lines of:

Is the User-Agent line in robots.txt an exact match or a substring match?

百般思念 提交于 2019-11-29 15:05:43
When a crawler reads the User-Agent line of a robots.txt file, does it attempt to match it exactly to its own User-Agent or does it attempt to match it as a substring of its User-Agent? Everything I have read does not explicitly answer this question. According to another StackOverflow thread it is an exact match. However, the RFC draft makes me believe that it is a substring match. For example, User-Agent: Google will match "Googlebot" and "Googlebot-News". Here is the relevant quotation from the RFC: The robot must obey the first record in /robots.txt that contains a User-Agent line whose

ASP.net not generating javascript for some User Agents

被刻印的时光 ゝ 提交于 2019-11-29 14:24:18
********************Edit 2********************** I figured out the problem... But I don't like the implications. I was testing our iPhone targeted mobile application earlier and using a plugin to mask Firefox's User Agent String as an iPhone. .Net was infact NOT generating the required code for post backs based on that piece of information alone. I do not like this however, because since the iPhone and other multimedia devices can interpret javascript, ASP.net is breaking any application that relies on server generated javascript to run. So, if the community will allow it... I'd like to change

Change User-Agent

杀马特。学长 韩版系。学妹 提交于 2019-11-29 12:42:41
How can I change in my WebView the default string of User-Agent? @IBOutlet weak var myWbView: UIWebView! let myURL = NSURL(string: "http://http://web-example") let myURLRequest:NSURLRequest = NSURLRequest(URL: myURL!) myWbView.loadRequest(myURLRequest) Alexander Tkachenko If you want to set User-Agent HTTP header for your request that is going to be used for Web-view loading, let userAgent = "Custom User Agent"; let myURL = NSURL(string: "http://http://web-example") let myURLRequest:NSURLRequest = NSMutableURLRequest(URL: myURL!) myWbView.loadRequest(myURLRequest) myURLRequest.setValue

Detect mobile devices with Django and Python 3

时光毁灭记忆、已成空白 提交于 2019-11-29 12:01:17
问题 I am struggling to find an easy way to detect if the request comes from a mobile device in my Django views. I am trying to implement something like this: #views.py def myfunction(request): ... if request.mobile: is_mobile = True else: is_mobile = False context = { ... , 'is_mobile': is_mobile, } return render(request, 'mytemplate.html', context) And in mytemplate.html : {% if is_mobile %} show something {% else %} show something else {% endif %} Everywhere I checked (for instance here or here