Coder Social home page Coder Social logo

picturepan2 / modern-random-ua Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arkcore/modern-random-ua

0.0 3.0 0.0 419 KB

Randomly generates User-Agent strings based on actual usage statistics from Wikipedia and StatOwl.com as of July 2012.

License: Other

JavaScript 100.00%

modern-random-ua's Introduction

random-ua.js - A random User-Agent Generator

Randomly generates User-Agent strings based on actual browser market share and usage statistics.

Old browser versions removed from this fork

Caveats

The version numbers generated are sane, however, revisions are totally random and unlikely to exist in the wild.

I decided not to include language selection found in the PHP version and instead include all the languages in the ISO639-2 standard because it's atypical for sites to determine client locale based on the user-agent.

Usage

var random_ua = require('modern-random-ua');

console.log(random_ua.generate());
//Easy like Sunday morning

//You can easily use random_ua to generate a random User-Agent for an HTTP request:

var http = require('http');

http.get({
        host:'whatsmyuseragent.com',
        path:'/',
        headers:{
            'User-Agent':random_ua.generate()
        }
    },
    function (res) {
        if (res.statusCode === 200) {
            var body = [];
            res.setEncoding('utf8');
            res.on('data', function (chunk) {
                body.push(chunk);
            });
            res.on('end', function () {
                body = body.join('');
                console.log(body);
            });
        } else {
            console.log('Error retrieving page: ' + res.statusCode);
        }
    }
);

Options

Please send your suggestions for improvements or updates.

Based Upon

This script is roughly based upon Luka Pusic's PHP script: http://360percents.com/posts/php-random-user-agent-generator/

A refactored version in PHP is available on GitHub at: https://raw.github.com/mwhite/random-uagent/

License

MIT License

modern-random-ua's People

Contributors

afoninsky avatar avvs avatar bitdeli-chef avatar jmealo avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.