Coder Social home page Coder Social logo

random-useragent's Introduction

random-useragent

NPM version Build Status Code Climate Coverage Status

NPM

Description

Get a random user agent (with an optional filter to select from a specific set of user agents).

Getting Started

Install the module with: npm install random-useragent

const randomUseragent = require('random-useragent');
randomUseragent.getRandom(); // gets a random user agent string

Documentation

.getRandom(filter)

Get a random user agent string (optionally using a filter).

Example Result:

'Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0';

.getRandomData(filter)

Get a random user agent's parsed data (optionally using a filter).

Example Result:

{
	"folder": "/Browsers - Windows/Legacy Browsers",
	"description": "Firefox 20.0 (Win 8 32)",
	"userAgent": "Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0",
	"appCodename": "",
	"appName": "",
	"appVersion": "",
	"platform": "",
	"vendor": "",
	"vendorSub": "",
	"browserName": "Firefox",
	"browserMajor": "20",
	"browserVersion": "20.0",
	"deviceModel": "",
	"deviceType": "",
	"deviceVendor": "",
	"engineName": "Gecko",
	"engineVersion": "20.0",
	"osName": "Windows",
	"osVersion": "8",
	"cpuArchitecture": ""
}

.getAll(filter)

Get an array of all the user agent strings (optionally using a filter).

.getAllData(filter)

Get an array of all the parsed user agent data (optionally using a filter).

Examples

Get a random user agent string:

randomUseragent.getRandom();

Get a random Firefox user agent string:

randomUseragent.getRandom(function (ua) {
  return ua.browserName === 'Firefox';
});

Get a random user agent with a version >= 20:

randomUseragent.getRandom(function (ua) {
  return parseFloat(ua.browserVersion) >= 20;
});

Source Of User Agents

The collection of user agents is pulled from the large, regularly updated xml file provided by the author of User Agent Switcher, which is located here:

Links

License

Copyright (c) 2014 skratchdot
Licensed under the MIT license.

random-useragent's People

Contributors

athieriot avatar davideviolante avatar mrvoltz avatar skratchdot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

random-useragent's Issues

useragents are blocked by cloudfare

I'm using puppeteer to scrape manga sites for latest episodes. When I use the random user agents, the scraper is being blocked automatically. The user agents needs some updates and be tested against Cloud fare.

UA mobile

Cant I generate random UA for mobile?

Filter documentation

Would you be able to provide documentation for the filters? For example, what criteria can be filtered on, and what values each criteria can take?

Add type definition for random-useragent package

Dear, Author/Maintainer of random-useragent package.

I just submitted a PR to DefinitelyTyped for this package's type definition. I use your package in my project and I found that there is no type definition yet for this package, so I created the ambient module first, then I create PR for the type.

Please feel free to review my PR at DefinitelyTyped/DefinitelyTyped#35493 in case there is a wrong definition or other problems. Thank you. ๐Ÿ™‡โ€โ™‚๏ธ

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.