Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

user-agents

Package Overview
Dependencies
Maintainers
1
Versions
2174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

user-agents - npm Package Compare versions

Comparing version 0.0.2 to 0.0.4

.babelrc

53

package.json
{
"name": "user-agents",
"version": "0.0.2",
"description": "Exports a list of various user-agents, useful for scraping ",
"main": "index.js",
"keywords": [
"scraping",
"user-agent"
],
"author": {
"name" : "Vitaly Aminev",
"email": "getstarted@avvs.co"
"version": "0.0.4",
"description": "A JavaScript library for generating random user agents. ",
"main": "dist/index.js",
"repository": "git@github.com:intoli/user-agents.git",
"author": "Intoli, LLC <contact@intoli.com>",
"license": "BSD-2-Clause",
"private": false,
"scripts": {
"build": "NODE_ENV=production webpack",
"lint": "eslint src/",
"postversion": "git push && git push --tags",
"test": "NODE_ENV=testing mocha --exit --require babel-register",
"update-data": "babel-node src/update-data.js src/user-agents.json"
},
"license": "MIT"
}
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-loader": "^7.1.4",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-power-assert": "^2.0.0",
"babel-register": "^6.26.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.12.0",
"imports-loader": "^0.8.0",
"mocha": "^5.2.0",
"power-assert": "^1.5.0",
"source-map-support": "^0.5.6",
"webpack": "^4.10.2",
"webpack-cli": "^2.1.4"
},
"dependencies": {
"cheerio": "^1.0.0-rc.2",
"dot-json": "^1.0.4"
}
}

@@ -1,5 +0,62 @@

# User agents list
simply export a list, or get a random user-agent header:
var agents = require('user-agents');
var agent = agents.random();
# User Agents
User Agents is a JavaScript module for generating random user agents according to how frequently they're used in the wild.
This is useful for web scraping because it's often desired to create realistic traffic patterns.
There are several other similar projects for generating random user agents, but User Agents is the only one that automatically publishes new versions with updated data on a regular basis.
This ensures that your user agents will always be realistic and up to date.
## Installation
The User Agents package is available on npm with the package name [user-agents](https://npmjs.com/package/user-agents).
You can install it using your favorite JavaScript package manager in the usual way.
```bash
# With npm: npm install user-agents
# With pnpm: pnpm install user-agents
# With yarn:
yarn add user-agents
```
## Usage
The `userAgents.random()` method can be used to generate a random user agent.
The most common user agents are weighted with higher probabilities so that the randomly generated user agents will follow realistic probability distributions.
For example, the following code snippet will generate five random user agents based on these probabilities.
```javascript
// Import the User Agents package.
const userAgents = require('user-agents');
// Log out five random user agents.
for (let i = 0; i < 5; i++) {
const userAgent = userAgents.random();
console.log(userAgents);
};
```
The output will be random, and will also depend on which package version you're using, but a typical output would look something like this.
```literal
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
```
## Acknowledgements
The user agent frequency data used in this library is currently provided by the [Will's House Tech Blog](https://techblog.willshouse.com/2012/01/03/most-common-user-agents/).
## Contributing
Contributions are welcome, but please follow these contributor guidelines outlined in [CONTRIBUTING.md](CONTRIBUTING.md).
## License
Slice is licensed under a [BSD 2-Clause License](LICENSE) and is copyright [Intoli, LLC](https://intoli.com).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc