getuseragent


Namegetuseragent JSON
Version 0.0.7 PyPI version JSON
download
home_pagehttps://github.com/pbiswell/getuseragent
SummaryGet a random, popular, commonly-used user agent string. Random/fake/spoof user agents.
upload_time2021-06-09 20:43:23
maintainer
docs_urlNone
authorPaul Biswell
requires_python
license
keywords getuseragent get user agent random user agent fake user agent fake useragent random useragent spoof useragent spoof user agent get useragent useragent user agent
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GetUserAgent - Random/Fake/Spoof Common User Agents

**Table of Contents**
- [GetUserAgent - Random/Fake/Spoof Common User Agents](#getuseragent---randomfakespoof-common-user-agents)
  - [Intro](#intro)
  - [Installation](#installation)
  - [Features](#features)
  - [Use Cases](#use-cases)
  - [Code Examples](#code-examples)
    - [Initialisation](#initialisation)
    - [User-Agents Available](#user-agents-available)
    - [Combination](#combination)
    - [Print Random User Agent From List](#print-random-user-agent-from-list)
    - [Performance / Limiting](#performance--limiting)
    - [Requests Handler](#requests-handler)
  - [To Do](#to-do)
  - [Changes](#changes)
## Intro

This is just a simple python module to produce a random, commonly used user agents each time. It contains 11 lists for a total of 1,100 user agents. You can choose and combine lists depending on your needs.

## Installation

Assumes you have python3 installed.

```
pip install getuseragent
```

## Features

- Get a random user agent of Chrome, Firefox, Safari, Edge, IE, Android, iOS, Windows, Mac, Linux, Desktop, Mobile, Bots, or any combination
- User-Agents from 100 of the most commonly used
- Add requests handler prefix
- Spoofed or fake user agents
- Combine multiple user agent lists

## Use Cases

- Check that your website statistics are identifying browsers correctly
- Handle bots visiting your website
- Making a security system to detect fake user agents?

## Code Examples

### Initialisation

```python
from getuseragent import UserAgent

useragent = UserAgent()

theuseragent = useragent.Random()
print(theuseragent)
```

Example output:

```
Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
```

### User-Agents Available

Each of the following lists contains 100 commonly used user agents for that software/device/system.

```python
# Firefox
useragent = UserAgent("firefox")

# Chrome
useragent = UserAgent("chrome")

# Safari
useragent = UserAgent("safari")

# Internet Explorer (IE)
useragent = UserAgent("ie")

# Edge
useragent = UserAgent("edge")

# iOS
useragent = UserAgent("ios")

# Android
useragent = UserAgent("android")

# Windows
useragent = UserAgent("windows")

# Mac
useragent = UserAgent("mac")

# Linux
useragent = UserAgent("linux")
```

Sets including multiple lists:

```python
# Desktop (Windows + Mac + Linux)
useragent = UserAgent("desktop")

# Mobile (iOS + Android)
useragent = UserAgent("mobile")

# All (Everything except bots)
useragent = UserAgent()
# or
useragent = UserAgent("all")
```

Bots like web crawlers:

```python
# Bots
useragent = UserAgent("bots")
```

### Combination

You can combine lists and sets together. Use the + sign between list names. Duplicate lists will automatically be removed so there's only 1 of each list at most.

Examples:

```python
# Chrome and Edge and iOS
useragent = UserAgent("chrome+edge+ios")

# Mobile + Firefox
useragent = UserAgent("mobile+firefox")

# All + Bots
useragent = UserAgent("all+bots")

# Print a random user agent based on your selection:
print(useragent.Random())
```

### Print Random User Agent From List

You can print a single random user agent like so:

```python
# Initialise
useragent = UserAgent()

# Get one random user agent
ua = useragent.Random()

# Print user agent
print(ua)
```

### Performance / Limiting

You can limit the total amount of user agents in the list to save memory. The default is no limit, and each list has 100 commonly used user agents.

```python
# Using 3 lists would make the total available user agents 300
useragent = UserAgent("chrome+firefox+ios")

# You can limit the total to, for example, 50:
# (List is randomised before truncating)
useragent = UserAgent("chrome+firefox+ios", total=50)

# You can limit individual lists
# This would give 10 firefox user agents + 10 safari user agents
# The total amount of user agents available would be 20
useragent = UserAgent("firefox+safari", limit=10)

# You can combine limit and total
# This would get 10 user agents for both android and ie, for 20 user agents
# The list would be randomised, then reduced to 15 total available user agents
useragent = UserAgent("android+ie", limit=10, total=15)

# Print a random user agent
print(useragent.Random())
```

### Requests Handler

You can enable the option to return your user agents ready to be used with the requests module.

```python
# Example
import requests
from getuseragent import UserAgent

myuseragent = UserAgent("all", requestsPrefix=True).Random()

# Example Output:
# --
# {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0'}

page = requests.get("https://google.com", headers=myuseragent)
```

## To Do

- Error handling
- Retrieve updated, most popular user-agents from the internet
- Better performance
- Hot-swappable lists
- Custom list(s)
- Command line arguments
- Improve Readme

## Changes

- 0.0.7 (June 9th, 2021)

```
1. Added individual list limits, which can be used when using one or multiple lists.
For example, if you used:

UserAgent("firefox+ios", limit=5)

It would limit each list to 5 user agents, and two lists, bringing the total user agents 10.

2. Checks if user agent files exist.
3. Checks if user list empty in Random()
```

- 0.0.2 - 0.0.6
  
```
Fixed package errors, spelling mistakes
```

- 0.0.1

```
Initial release
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pbiswell/getuseragent",
    "name": "getuseragent",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "getuseragent,get user agent,random user agent,fake user agent,fake useragent,random useragent,spoof useragent,spoof user agent,get useragent,useragent,user agent",
    "author": "Paul Biswell",
    "author_email": "pblabsdev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/49/a3/189cf72d47cfaa039d36df537281d740c35823af87f95ce2c48c68499735/getuseragent-0.0.7.tar.gz",
    "platform": "",
    "description": "# GetUserAgent - Random/Fake/Spoof Common User Agents\n\n**Table of Contents**\n- [GetUserAgent - Random/Fake/Spoof Common User Agents](#getuseragent---randomfakespoof-common-user-agents)\n  - [Intro](#intro)\n  - [Installation](#installation)\n  - [Features](#features)\n  - [Use Cases](#use-cases)\n  - [Code Examples](#code-examples)\n    - [Initialisation](#initialisation)\n    - [User-Agents Available](#user-agents-available)\n    - [Combination](#combination)\n    - [Print Random User Agent From List](#print-random-user-agent-from-list)\n    - [Performance / Limiting](#performance--limiting)\n    - [Requests Handler](#requests-handler)\n  - [To Do](#to-do)\n  - [Changes](#changes)\n## Intro\n\nThis is just a simple python module to produce a random, commonly used user agents each time. It contains 11 lists for a total of 1,100 user agents. You can choose and combine lists depending on your needs.\n\n## Installation\n\nAssumes you have python3 installed.\n\n```\npip install getuseragent\n```\n\n## Features\n\n- Get a random user agent of Chrome, Firefox, Safari, Edge, IE, Android, iOS, Windows, Mac, Linux, Desktop, Mobile, Bots, or any combination\n- User-Agents from 100 of the most commonly used\n- Add requests handler prefix\n- Spoofed or fake user agents\n- Combine multiple user agent lists\n\n## Use Cases\n\n- Check that your website statistics are identifying browsers correctly\n- Handle bots visiting your website\n- Making a security system to detect fake user agents?\n\n## Code Examples\n\n### Initialisation\n\n```python\nfrom getuseragent import UserAgent\n\nuseragent = UserAgent()\n\ntheuseragent = useragent.Random()\nprint(theuseragent)\n```\n\nExample output:\n\n```\nMozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148\n```\n\n### User-Agents Available\n\nEach of the following lists contains 100 commonly used user agents for that software/device/system.\n\n```python\n# Firefox\nuseragent = UserAgent(\"firefox\")\n\n# Chrome\nuseragent = UserAgent(\"chrome\")\n\n# Safari\nuseragent = UserAgent(\"safari\")\n\n# Internet Explorer (IE)\nuseragent = UserAgent(\"ie\")\n\n# Edge\nuseragent = UserAgent(\"edge\")\n\n# iOS\nuseragent = UserAgent(\"ios\")\n\n# Android\nuseragent = UserAgent(\"android\")\n\n# Windows\nuseragent = UserAgent(\"windows\")\n\n# Mac\nuseragent = UserAgent(\"mac\")\n\n# Linux\nuseragent = UserAgent(\"linux\")\n```\n\nSets including multiple lists:\n\n```python\n# Desktop (Windows + Mac + Linux)\nuseragent = UserAgent(\"desktop\")\n\n# Mobile (iOS + Android)\nuseragent = UserAgent(\"mobile\")\n\n# All (Everything except bots)\nuseragent = UserAgent()\n# or\nuseragent = UserAgent(\"all\")\n```\n\nBots like web crawlers:\n\n```python\n# Bots\nuseragent = UserAgent(\"bots\")\n```\n\n### Combination\n\nYou can combine lists and sets together. Use the + sign between list names. Duplicate lists will automatically be removed so there's only 1 of each list at most.\n\nExamples:\n\n```python\n# Chrome and Edge and iOS\nuseragent = UserAgent(\"chrome+edge+ios\")\n\n# Mobile + Firefox\nuseragent = UserAgent(\"mobile+firefox\")\n\n# All + Bots\nuseragent = UserAgent(\"all+bots\")\n\n# Print a random user agent based on your selection:\nprint(useragent.Random())\n```\n\n### Print Random User Agent From List\n\nYou can print a single random user agent like so:\n\n```python\n# Initialise\nuseragent = UserAgent()\n\n# Get one random user agent\nua = useragent.Random()\n\n# Print user agent\nprint(ua)\n```\n\n### Performance / Limiting\n\nYou can limit the total amount of user agents in the list to save memory. The default is no limit, and each list has 100 commonly used user agents.\n\n```python\n# Using 3 lists would make the total available user agents 300\nuseragent = UserAgent(\"chrome+firefox+ios\")\n\n# You can limit the total to, for example, 50:\n# (List is randomised before truncating)\nuseragent = UserAgent(\"chrome+firefox+ios\", total=50)\n\n# You can limit individual lists\n# This would give 10 firefox user agents + 10 safari user agents\n# The total amount of user agents available would be 20\nuseragent = UserAgent(\"firefox+safari\", limit=10)\n\n# You can combine limit and total\n# This would get 10 user agents for both android and ie, for 20 user agents\n# The list would be randomised, then reduced to 15 total available user agents\nuseragent = UserAgent(\"android+ie\", limit=10, total=15)\n\n# Print a random user agent\nprint(useragent.Random())\n```\n\n### Requests Handler\n\nYou can enable the option to return your user agents ready to be used with the requests module.\n\n```python\n# Example\nimport requests\nfrom getuseragent import UserAgent\n\nmyuseragent = UserAgent(\"all\", requestsPrefix=True).Random()\n\n# Example Output:\n# --\n# {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0'}\n\npage = requests.get(\"https://google.com\", headers=myuseragent)\n```\n\n## To Do\n\n- Error handling\n- Retrieve updated, most popular user-agents from the internet\n- Better performance\n- Hot-swappable lists\n- Custom list(s)\n- Command line arguments\n- Improve Readme\n\n## Changes\n\n- 0.0.7 (June 9th, 2021)\n\n```\n1. Added individual list limits, which can be used when using one or multiple lists.\nFor example, if you used:\n\nUserAgent(\"firefox+ios\", limit=5)\n\nIt would limit each list to 5 user agents, and two lists, bringing the total user agents 10.\n\n2. Checks if user agent files exist.\n3. Checks if user list empty in Random()\n```\n\n- 0.0.2 - 0.0.6\n  \n```\nFixed package errors, spelling mistakes\n```\n\n- 0.0.1\n\n```\nInitial release\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Get a random, popular, commonly-used user agent string. Random/fake/spoof user agents.",
    "version": "0.0.7",
    "split_keywords": [
        "getuseragent",
        "get user agent",
        "random user agent",
        "fake user agent",
        "fake useragent",
        "random useragent",
        "spoof useragent",
        "spoof user agent",
        "get useragent",
        "useragent",
        "user agent"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "a824edf0e44921762f58904d5c95a3b3",
                "sha256": "faf29ae99771e3e0a9f28912161092988dad3c8183dcbe6de9ee063bf45e0b32"
            },
            "downloads": -1,
            "filename": "getuseragent-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a824edf0e44921762f58904d5c95a3b3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 25600,
            "upload_time": "2021-06-09T20:43:21",
            "upload_time_iso_8601": "2021-06-09T20:43:21.290304Z",
            "url": "https://files.pythonhosted.org/packages/97/96/8f5451cbf1b862614a168764356108eefa5f07b585de7c3ece3110d6fe93/getuseragent-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "c38b18173293befea812b37406bdf05e",
                "sha256": "fdfa80651e787771142f711ac120dc7bfb852a13fb4525087605149e57ab196b"
            },
            "downloads": -1,
            "filename": "getuseragent-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "c38b18173293befea812b37406bdf05e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 24486,
            "upload_time": "2021-06-09T20:43:23",
            "upload_time_iso_8601": "2021-06-09T20:43:23.946644Z",
            "url": "https://files.pythonhosted.org/packages/49/a3/189cf72d47cfaa039d36df537281d740c35823af87f95ce2c48c68499735/getuseragent-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-06-09 20:43:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pbiswell",
    "github_project": "getuseragent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "getuseragent"
}
        
Elapsed time: 0.04162s