<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          DeviceDetectorUser-Agent 解析庫

          聯(lián)合創(chuàng)作 · 2023-09-28 16:23

          DeviceDetector 是一個用 Ruby 編寫的用來解析各種設備 User-Agent 信息的庫,基于及時更新和龐大的 user-agent 庫。使用 DeviceDetector 可探測設備瀏覽器、操作系統(tǒng)、設備類型(桌面、平板、移動、電視、汽車、控制臺等)、品牌和型號。

          示例代碼:

          user_agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36'
          client = DeviceDetector.new(user_agent)
          
          client.name # => 'Chrome'
          client.full_version # => '30.0.1599.69'
          
          client.os_name # => 'Windows'
          client.os_full_version # => '8'
          
          # For many devices, you can also query the device name (usually the model name)
          client.device_name # => 'iPhone 5'
          # Device types can be one of the following: smartphone, tablet, console, 
          # portable media player, tv, car browser, camera
          client.device_type # => 'smartphone'

          為了提升性能,DeviceDetector 可以把 UserAgent 信息放到緩存中:

          DeviceDetector.configure do |config|
            config.max_cache_keys = 5_000 
            # increment this if you have enough RAM, proceed with care
          end
          瀏覽 18
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  操逼网站123 | 人人操人人操人人操 | 爱草在线| 老鸭窝成人 | 亚洲欧美动漫 |