zoukankan      html  css  js  c++  java
  • What is HTTP_USER_AGENT?

    http://perl.about.com/od/cgiprogramminginperl/a/020905.htm

    How to identify a browser

    HTTP_USER_AGENT is one of the 19 CGI environment variables defined by The National Center for Supercomputing Applications (NCSA). It is used to identify the user agent that the client is using when a CGI script is accessed from a web page.

    What is a user agent?

    A user agent is the application a client uses to access a web page, which may be a browser, a mobile device or service such as AvantGo, or web crawlers, among other things. HTTP_USER_AGENT is the CGI environment variable that is generated to identify the user agent, and this information may be used to good effect if you want to present specific pages to your users based on what they're using to view the page. It's also handy if you want to use the robots.txt file to exclude a crawler from your site, or particular sections of your site.

    What does the HTTP_USER_AGENT string look like?

    Typically, the information included in HTTP_USER_AGENT includes the name of the client application and version, the operating system used by the host, and the language. Other information may also be included, such as a URL or email address.

    Some of the strings identifying browsers are a little confusing, and this stems from the struggle for browser dominance. As one browser gains popularity, web sites may cater to it, or exclude other browsers entirely, even though they may handle complex pages being sent to it. Therefore, some browsers send a spoofed or cloaked string so that the page content will be retrieved properly.

    For example, early versions of Internet Explorer sent an HTTP_USER_AGENT string identifying it as Mozilla, which was then used by Netscape Navigator. Now that Internet Explorer has gained dominance, some newer browsers follow in the same tradition, identifying themselves as Mozilla, MSIE, and the correct browser name.

    Here are some examples
    ===
    Internet Explorer
    Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
    Mozilla/4.0 (compatible; MSIE 4.0 Crawler; Windows 95)

    Netscape Navigator
    Mozilla/4.0b1 (Win95; I)
    Mozilla/3.01Gold (Macintosh; U; PPC)
    ===

    How can I know the correct user agent?

    The easiest way to have the correct user agent at your fingertips is to use a compiled list. A good one is presented by Zytrax, and Siteware Technologies.

  • 相关阅读:
    python_内置函数
    python_函数进阶3
    python_函数进阶2
    微信后台的编辑模式的使用
    struts2中action的XXX_* metend={1}
    POI导出excel
    使用mybatis生成相关文件时java.sql.SQLException: Access denied for user 'root'@'localhost' (using password)
    freecms使用jsoup和quartz抓取其他网站内容
    freecms首页静态化以及模板标签 (2)
    freecms中后台添加导出excel表格功能
  • 原文地址:https://www.cnblogs.com/ctoroad/p/285745.html
Copyright © 2011-2022 走看看