Skip to main content

Python Browscap Library.

Project description

Detect browser

import redis
import browscap
from browscap.cache.redis import RedisCache

ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"
redis_cache = redis.Redis(db=5)
bc = browscap.Browscap(cache=RedisCache(redis_cache))
browser=bc.get_browser(ua)

Detect browser with asyncio

from pprint import pprint
import asyncio
import asyncio_redis
from browscap.aio import BrowscapAsync
from browscap.aio.cache.redis import RedisPoolAioCache

loop = asyncio.get_event_loop()

@asyncio.coroutine
def get_browser():
    ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"

    redis_cache = await aioredis.create_pool(('localhost', 6379), minsize=5, maxsize=100)
    bc = BrowscapAsync(cache=RedisPoolAioCache(redis_cache))
    browser = yield from bc.get_browser(ua)

    cache.close_connection()
    return browser


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    browser = loop.run_until_complete(get_browser())
    pprint(browser)

Update base

import redis
import browscap
from browscap.cache.redis import RedisCache
from browscap import IniLoader

redis_cache = redis.Redis(db=5)
bc = browscap.Browscap(cache=RedisCache(redis_cache))
bc.update(type=IniLoader.PHP_INI_FULL)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

browscap-python-0.0.16.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

browscap_python-0.0.16-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file browscap-python-0.0.16.tar.gz.

File metadata

  • Download URL: browscap-python-0.0.16.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for browscap-python-0.0.16.tar.gz
Algorithm Hash digest
SHA256 3ed800cb091787a3a63655a4b6b12e3e46f5e2e2c83704ce485525f417e04f30
MD5 97078371fa95daa7698ba4b8f7d69ec7
BLAKE2b-256 2be48c78c91c1bed36dd810bd273f06720ee86477601345d3c45446db87969e3

See more details on using hashes here.

File details

Details for the file browscap_python-0.0.16-py3-none-any.whl.

File metadata

  • Download URL: browscap_python-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for browscap_python-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 5630be84657a0f3729fba5ba86319535861bc89391a6b6b4cfeabd217252dbf5
MD5 99f6eb8c7de642f92d54bf4de625f9ba
BLAKE2b-256 77dd64beb678804f6bec0514840e2f11020fc34e2f6fdb557378313de0a4d23a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page