real-user-agent
Will the real user agent please stand up?
![License: ISC](https://img.shields.io/npm/l/real-user-agent.svg)
Get an up-to-date user-agent string, sourced from the most common user agents. To avoid each use of this module hammering the source, the data is now self-hosted with a gist, updated in the build process. A simple local cache, invalidated every 2 hours, prevents extra requests. A data cap is implemented in the request. There is a fallback string in case the data is corrupt or host is unreachable.
const userAgent = require('real-user-agent');
const ua = await userAgent();
const topTen = await userAgent.all();
const randomUA = await userAgent.cycle();
const anotherUA = await userAgent.cycle();
const fifth = await userAgent.cycle(4);
const randomUA = await userAgent.cycle(Math.random());
const request = require('request');
const userAgent = require('real-user-agent');
request({
url: 'https://api.github.com/repos/fijimunkii/real-user-agent',
headers: {
'user-agent': await userAgent()
}
});
Authors
fijimunkii
License
This project is licensed under the ISC License - see the LICENSE file for details.