• Stars
    star
    317
  • Rank 132,216 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generator of User-Agent header

Documentation for user_agent package

Test Status Code Quality Type Check Documentation Status

What is user_agent module for?

This module is for generating random, valid web user agents:

  • content of "User-Agent" HTTP headers
  • content of window.navigator JavaScript object

Usage Example

>>> from user_agent import generate_user_agent, generate_navigator
>>> from pprint import pprint
>>> generate_user_agent()
'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.3; Win64; x64)'
>>> generate_user_agent(os=('mac', 'linux'))
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:36.0) Gecko/20100101 Firefox/36.0'
>>> pprint(generate_navigator())
{'app_code_name': 'Mozilla',
 'app_name': 'Netscape',
 'appversion': '5.0',
 'name': 'firefox',
 'os': 'linux',
 'oscpu': 'Linux i686 on x86_64',
 'platform': 'Linux i686 on x86_64',
 'user_agent': 'Mozilla/5.0 (X11; Ubuntu; Linux i686 on x86_64; rv:41.0) Gecko/20100101 Firefox/41.0',
 'version': '41.0'}
>>> pprint(generate_navigator_js())
{'appCodeName': 'Mozilla',
 'appName': 'Netscape',
 'appVersion': '38.0',
 'platform': 'MacIntel',
 'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Firefox/38.0'}

Command Line Usage

$ ua
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:49.0) Gecko/20100101 Firefox/49.0

$ ua -n chrome -e
{
  "oscpu": "Linux i686 on x86_64", 
  "appName": "Netscape", 
  "appCodeName": "Mozilla", 
  "appVersion": "55.0.2909.25", 
  "platform": "X11; Linux i686 on x86_64", 
  "userAgent": "Mozilla/5.0 (X11; Linux i686 on x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2909.25 Safari/537.36"
}

Installation

Run pip install -U user_agent

Documentation

Documentation is available at http://user-agent.readthedocs.org

Contribution

Use github to submit bug,fix or wish request: https://github.com/lorien/user_agent/issues

More Repositories

1

awesome-web-scraping

List of libraries, tools and APIs for web scraping and data processing.
Makefile
6,049
star
2

grab

Web Scraping Framework
Python
2,330
star
3

captcha_solver

Universal python API to captcha solving services
Python
229
star
4

awesome-osint

Yet another list of OSINT tools
99
star
5

awesome-pastebin

List of pastebin services
77
star
6

ru-osint-infosec-map

Graph of OSINT and InfoSec resources in Russian language
JavaScript
33
star
7

awesome-anti-captcha

Curated list of captcha solving software, libraries and API.
16
star
8

proxylist

Python library to work with proxy server items loaded from local file or network document.
Python
16
star
9

awesome-python-dev

List of tools for debugging, profiling and analyzing python programs.
12
star
10

selection

API to extract data from HTML and XML documents
Python
10
star
11

learning-web-scraping

A list of articles and books teaching web scraping
9
star
12

runscript

Simple script launcher
Python
8
star
13

procstat

A tool to count runtime metrics
Python
6
star
14

pyproject

Python Project Template for Cookiecutter
Makefile
6
star
15

badserver

Bad Bad Server
Python
4
star
16

awesome-geoint

Tools for GEOINT
4
star
17

3proxy_confgen

3proxy config generator to use upstream proxies
Python
4
star
18

unicodec

Tools to detect encoding and convert HTML bytes content to Unicode.
Python
3
star
19

mongodb_toolbox

Tools to automate mongodb read/write operations.
Python
3
star
20

test_server

Server to test HTTP clients
Python
3
star
21

iohub

Dashboard to monitor ioweb crawlers
Python
1
star
22

rucaptcha

Python library to access rucaptcha/twocaptcha API
Python
1
star
23

mongoenum

Script to enumerate sizes of mongodb databases, collections and indexes.
Python
1
star
24

captcha_solution

A simple interface to multiple captcha solving services
Python
1
star