user-agent

Mocking a useragent in javascript?

末鹿安然 提交于 2019-11-26 03:51:27
问题 I\'m looking for a way to programmatically change navigator.userAgent on the fly. In my failed attempt to get an automated javascript unit tester, I gave up and attempted to begin using fireunit. Immediately, I\'ve slammed into one of the walls of using an actual browser for javascript testing. Specifically, I need to change navigator.userAgent to simulate a few hundred userAgent strings to ensure proper detection and coverage on a given function. navigator.userAgent is readonly, so I seem

Changing the user agent of the WebBrowser control

人盡茶涼 提交于 2019-11-26 03:24:39
问题 I am trying to change the UserAgent of the WebBrowser control in a Winforms application. I have successfully achieved this by using the following code: [DllImport(\"urlmon.dll\", CharSet = CharSet.Ansi)] private static extern int UrlMkSetSessionOption( int dwOption, string pBuffer, int dwBufferLength, int dwReserved); const int URLMON_OPTION_USERAGENT = 0x10000001; public void ChangeUserAgent() { List<string> userAgent = new List<string>(); string ua = \"Googlebot/2.1 (+http://www.google.com

How to find the operating system version using JavaScript?

蹲街弑〆低调 提交于 2019-11-26 03:14:04
问题 How can I find the OS name and OS version using JavaScript? 回答1: If you list all of window.navigator 's properties using console.log(navigator); You'll see something like this # platform = Win32 # appCodeName = Mozilla # appName = Netscape # appVersion = 5.0 (Windows; en-US) # language = en-US # mimeTypes = [object MimeTypeArray] # oscpu = Windows NT 5.1 # vendor = Firefox # vendorSub = 1.0.7 # product = Gecko # productSub = 20050915 # plugins = [object PluginArray] # securityPolicy = #

What is the iPad user agent?

点点圈 提交于 2019-11-26 02:08:37
问题 From what I gather, the iPad is using iPhone OS, but with a different screen resolution from the iPhone and iPod touch. So many sites may have to change their user agent detection to adapt to the iPad. So, can anyone with access to the iPad or the iPad SDK give us the user-agent string? 回答1: Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10 回答2: From the simulator , in iPad mode: Mozilla/5.0

Changing the user agent of the WebBrowser control

廉价感情. 提交于 2019-11-26 01:46:43
I am trying to change the UserAgent of the WebBrowser control in a Winforms application. I have successfully achieved this by using the following code: [DllImport("urlmon.dll", CharSet = CharSet.Ansi)] private static extern int UrlMkSetSessionOption( int dwOption, string pBuffer, int dwBufferLength, int dwReserved); const int URLMON_OPTION_USERAGENT = 0x10000001; public void ChangeUserAgent() { List<string> userAgent = new List<string>(); string ua = "Googlebot/2.1 (+http://www.google.com/bot.html)"; UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, ua, ua.Length, 0); } The only problem is that

Determine a user&#39;s timezone

泪湿孤枕 提交于 2019-11-26 01:40:44
问题 Is there a standard way for a web server to be able to determine a user\'s timezone within a web page? Perhaps from an HTTP header or part of the user-agent string? 回答1: -new Date().getTimezoneOffset()/60; The method getTimezoneOffset() will subtract your time from GMT and return the number of minutes. So if you live in GMT-8, it will return 480. To put this into hours, divide by 60. Also, notice that the sign is the opposite of what you need - it's calculating GMT's offset from your time

Determine a user&#39;s timezone

て烟熏妆下的殇ゞ 提交于 2019-11-26 01:19:01
问题 Is there a standard way for a web server to be able to determine a user\'s timezone within a web page? Perhaps from an HTTP header or part of the user-agent string? 回答1: -new Date().getTimezoneOffset()/60; The method getTimezoneOffset() will subtract your time from GMT and return the number of minutes. So if you live in GMT-8, it will return 480. To put this into hours, divide by 60. Also, notice that the sign is the opposite of what you need - it's calculating GMT's offset from your time

Setting user agent of a java URLConnection

蓝咒 提交于 2019-11-26 00:25:26
问题 I\'m trying to parse a webpage using Java with URLConnection. I try to set up the user-agent like this: java.net.URLConnection c = url.openConnection(); c.setRequestProperty(\"User-Agent\", \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2\"); But the resulting user agent is the one I specify, with \"Java/1.5.0_19\" appended to the end. Is there a way to truly set the user agent without this addition? 回答1: Off hand, setting the http.agent system

Changing user agent on urllib2.urlopen

萝らか妹 提交于 2019-11-26 00:19:20
问题 How can I download a webpage with a user agent other than the default one on urllib2.urlopen? 回答1: Setting the User-Agent from everyone's favorite Dive Into Python. The short story: You can use Request.add_header to do this. You can also pass the headers as a dictionary when creating the Request itself, as the docs note: headers should be a dictionary, and will be treated as if add_header() was called with each key and value as arguments. This is often used to “spoof” the User-Agent header,

Get operating system info

邮差的信 提交于 2019-11-25 23:39:32
问题 I recently started wondering about sites like http://thismachine.info/ that get the user\'s operating system info. I have not been able to find out how to do that with PHP, and wanted to try to figure it out. I noticed that they list the user-agent , which gives lots of info about the browser. Do they get the operating system information from that, or from something else? Is there an API I could use to get the user\'s operating system? I see how they got the Browser and IP, but could not