• Stars
    star
    317
  • Rank 127,695 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year 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

lxmlbench

Simple benchmark to test CPU speed by parsing HTML with lxml
HTML
6
star
14

pyproject

Python Project Template for Cookiecutter
Makefile
6
star
15

procstat

A tool to count runtime metrics
Python
6
star
16

netbench

Testing python network libraries
Python
4
star
17

badserver

Bad Bad Server
Python
4
star
18

awesome-geoint

Tools for GEOINT
4
star
19

topsites

HTML of alexa top1k sites
HTML
4
star
20

3proxy_confgen

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

unicodec

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

mongodb_toolbox

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

test_server

Server to test HTTP clients
Python
3
star
24

iohub

Dashboard to monitor ioweb crawlers
Python
1
star
25

rucaptcha

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

mongoenum

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

ergotools

Python
1
star
28

captcha_solution

A simple interface to multiple captcha solving services
Python
1
star