intoli / user-agents Goto Github PK
View Code? Open in Web Editor NEWA JavaScript library for generating random user agents with data that's updated daily.
License: Other
A JavaScript library for generating random user agents with data that's updated daily.
License: Other
It seems like the data has not been actualized since one month ago, there is a problem with the CI pipeline, check it out, please.
I using user-agents but his not detect tablet device. I am testing with toggle device toolbar in chrome/
I get this object and detecting desktop.
appName: "Netscape"
connection: {downlink: 6.7, effectiveType: "4g", rtt: 200}
deviceCategory: "desktop"
platform: "Win32"
pluginsLength: 3
screenHeight: 768
screenWidth: 1366
userAgent: "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
vendor: "Google Inc."
viewportHeight: 630
viewportWidth: 1350
weight: 0.00016750821718497432
I've been fighting with this for a couple of hours and I can't seem to work out why I can't get the simple example to execute.
I'm sure I'm doing something incredibly stupid, so any help you could provide would be appreciated.
I'm currently using Node 10.11.0
and I'm getting the following error from the example:
import UserAgent from "user-agents";
const userAgent = new UserAgent();
console.log(userAgent.toString());
console.log(JSON.stringify(userAgent.data, null, 2));
node index.js
~/apps/bunraku/spike/index.js:1
(function (exports, require, module, __filename, __dirname) { import UserAgent from "user-agents";
^^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:279:19)
Here is my package.json
:
{
"name": "bunraku-spike",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"puppeteer": "^1.8.0",
"user-agents": "^1.0.28"
},
"devDependencies": {}
}
And my package-lock.json
:
{
"name": "bunraku-spike",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"agent-base": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz",
"integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==",
"requires": {
"es6-promisify": "^5.0.0"
}
},
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"requires": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^2.2.2",
"typedarray": "^0.0.6"
}
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"debug": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.5.tgz",
"integrity": "sha512-D61LaDQPQkxJ5AUM2mbSJRbPkNs/TmdmOeLAi1hgDkpDfIfetSrjmWhccwtuResSwMbACjx/xXQofvM9CE/aeg==",
"requires": {
"ms": "^2.1.1"
}
},
"docopt": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/docopt/-/docopt-0.6.2.tgz",
"integrity": "sha1-so6eIiDaXsSffqW7JKR3h0Be6xE="
},
"dot-json": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/dot-json/-/dot-json-1.0.4.tgz",
"integrity": "sha1-tcWBjrUmp5F6wC3wF/6fujexEZU=",
"requires": {
"docopt": "~0.6.2",
"underscore-keypath": "~0.0.22"
}
},
"es6-promise": {
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz",
"integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg=="
},
"es6-promisify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
"requires": {
"es6-promise": "^4.0.3"
}
},
"extract-zip": {
"version": "1.6.7",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz",
"integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=",
"requires": {
"concat-stream": "1.6.2",
"debug": "2.6.9",
"mkdirp": "0.5.1",
"yauzl": "2.4.1"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"fd-slicer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
"integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
"requires": {
"pend": "~1.2.0"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"glob": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"https-proxy-agent": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz",
"integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==",
"requires": {
"agent-base": "^4.1.0",
"debug": "^3.1.0"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"lodash.clonedeep": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
"integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
},
"mime": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.3.1.tgz",
"integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg=="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
},
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
},
"progress": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz",
"integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8="
},
"proxy-from-env": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz",
"integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4="
},
"puppeteer": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.8.0.tgz",
"integrity": "sha512-wJ7Fxs03l4dy/ZXQACUKBBobIuJaS4NHq44q7/QinpAXFMwJMJFEIPjzoksVzUhZxQe+RXnjXH69mg13yMh0BA==",
"requires": {
"debug": "^3.1.0",
"extract-zip": "^1.6.6",
"https-proxy-agent": "^2.2.1",
"mime": "^2.0.3",
"progress": "^2.0.0",
"proxy-from-env": "^1.0.0",
"rimraf": "^2.6.1",
"ws": "^5.1.1"
}
},
"readable-stream": {
"version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"rimraf": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"requires": {
"glob": "^7.0.5"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": {
"safe-buffer": "~5.1.0"
}
},
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"underscore": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
"integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg=="
},
"underscore-keypath": {
"version": "0.0.22",
"resolved": "https://registry.npmjs.org/underscore-keypath/-/underscore-keypath-0.0.22.tgz",
"integrity": "sha1-SKUoOSu278QkvhyqVtpLX6zPJk0=",
"requires": {
"underscore": "*"
}
},
"user-agents": {
"version": "1.0.28",
"resolved": "https://registry.npmjs.org/user-agents/-/user-agents-1.0.28.tgz",
"integrity": "sha512-g9I42OhFzs3Yh+M9TMwCrMW7znbNKBhhoFWGBLuj/JoAUH4Che3UnH/Yn+X/08aD9WAJyg7LtED7GqQcYNr1/A==",
"requires": {
"dot-json": "^1.0.4",
"lodash.clonedeep": "^4.5.0"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"ws": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
"requires": {
"async-limiter": "~1.0.0"
}
},
"yauzl": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
"integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=",
"requires": {
"fd-slicer": "~1.0.1"
}
}
}
}
Hi,
Do you know if your library replicated in GO?
If No, I was wondering if you'd accept to have your library replicated in GO?
I can do it if you want as I would very much like to have your intoli/user-agents library available in a GO environment.
Have a great day,
later than this version [email protected] i get this error "TypeError: UserAgent is not a constructor" i dont know what it causes
import UserAgent from 'user-agents';
const userAgent = new UserAgent();
console.log(userAgent.toString())
console.log(userAgent.data)
I only see 6 instances of the word 'Firefox' among the user agents. This would result in a fingerprint in itself after multiple requests due to the unnatural distribution of browsers.
Hi, I'm trying differents browser detection libraries with user agent.
This library have a very big problems detecting browser and other data.
Can try here: https://csb-ivpk9-hetehawso.now.sh/
Reload the page and see how changes browser, os, version, etc. every time.
How to properly imitate browser in puppeteer? Currently I use this:
const puppeteer = require('puppeteer-extra')
const pluginStealth = require("puppeteer-extra-plugin-stealth");
(async () => {
console.log(proxy.url);
puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
args: [
`--window-size=${ua.data.viewportWidth},${ua.data.viewportHeight + windowFrame}`,
]
}).then(async browser => {
puppeteer.use(pluginStealth({
enabledEvasions: new Set([
'chrome.runtime',
'console.debug',
'navigator.languages',
'navigator.permissions',
'navigator.webdriver',
'navigator.plugins',
'window.outerdimensions',
'webgl.vendor',
'user-agent'
])
}));
const page = await browser.newPage();
await page.setExtraHTTPHeaders({
'Accept-Language': 'en-US,en;q=0.9',
'Accept-Encoding': 'gzip, deflate, br'
});
await page.setViewport({
width: ua.data.viewportWidth,
height: ua.data.viewportHeight
});
await page.setUserAgent(ua.toString());
await page.evaluateOnNewDocument((uad, windowFrame) => {
Object.defineProperty(screen, 'width', {get: () => uad.screenWidth});
Object.defineProperty(screen, 'height', {get: () => uad.screenHeight});
Object.defineProperty(window, 'outerWidth', {get: () => uad.viewportWidth});
Object.defineProperty(window, 'outerHeight', {get: () => uad.viewportHeight + windowFrame});
Object.defineProperty(navigator, 'languages', {get: () => ['en-US', 'en']});
Object.defineProperty(navigator, 'language', {get: () => ['en-US']});
Object.defineProperty(navigator, 'connection', {get: () => uad.connection});
Object.defineProperty(navigator, 'cpuClass', {get: () => uad.cpuClass});
Object.defineProperty(navigator, 'oscpu', {get: () => uad.oscpu});
Object.defineProperty(navigator, 'platform', {get: () => uad.platform});
Object.defineProperty(navigator.plugins, 'length', {get: () => uad.pluginsLength});
Object.defineProperty(navigator, 'vendor', {get: () => uad.vendor});
if (uad.appName !== 'Chrome') {
Object.defineProperty(window, 'chrome', {get: () => undefined});
}
}, ua.data, windowFrame);
await page.goto('https://my-site.com/'), {waitUntil: 'networkidle0'};
})
I test it by watching realtime google analytics in realtime.
If I remove setUserAgent and evaluateOnNewDocument (though using raw pluginStealth) — mu hit displays at GA realtime report. If I enable all this — GA doesn't report hit — seems to be detected as a bot and ignored.
What am I doing wrong?
Just installed user-agents. Pasted in the basic example, and const userAgent = new UserAgent();
returns ReferenceError: UserAgent is not defined
I logged the variable which required user-agents and the package exists and is installed correctly. I'd hope this is an issue on my end because this seems like a promising package.
Thanks.
Is there any *.d.ts
file for typescript project?
I use typescript and get this error:
const userAgent = new user_agents_1.default();
^
TypeError: user_agents_1.default is not a constructor
at Object.<anonymous> (C:\Users\user\Desktop\new\sdfsdf.js:4:19)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:822:10)
at internal/main/run_main_module.js:17:11
code before compilation:
import UserAgent from 'user-agents';
const userAgent = new UserAgent();
console.log(userAgent.toString()); //
console.log(JSON.stringify(userAgent.data, null, 2));
code after compilation typescript:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const user_agents_1 = require("user-agents");
const userAgent = new user_agents_1.default();
console.log(userAgent.toString()); //
console.log(JSON.stringify(userAgent.data, null, 2));
I think it has something to do with: babel/babel#2212
I think this can be fixed using the plugin https://www.npmjs.com/package/babel-plugin-add-module-exports with a parameter addDefaultProperty
Currently the module generates mostly latest user-agents. Is there any possibility to get random old user-agents?
In recent versions of the package, a header containing emoji is included (posted below). This results in errors with lots of clients, including node-fetch and chromium fetch, with an error like this:
VM245:2 Uncaught TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'headers' property from 'RequestInit': String contains non ISO-8859-1 code point.
at <anonymous>:1:17
Can you avoid including user-agents outside of the ascii range?
Header:
{
"appName": "Forget about App Name.",
"connection": {
"downlink": 10,
"effectiveType": "4g",
"rtt": 50
},
"platform": "This is CODM platform",
"pluginsLength": 0,
"vendor": "Oja Vendor Agba. 😎",
"userAgent": "SUPERSTAR! the guy dey form superstar Chee..... 😹",
"viewportHeight": 660,
"viewportWidth": 1350,
"deviceCategory": "desktop",
"screenHeight": 768,
"screenWidth": 1366,
"weight": 0.00006628526257710449
},
I'm having issues with latest version of your package.
The following snippet gives me Chrome version that are <80
const ua = new UserAgent({ deviceCategory: "desktop" })
const userAgents = Array(100).fill().map(() => ua().toString())
I tried with ua(/Chrome\/83/)
to get the newest version, but the filter won't apply. Any help?
Thanks
By not using files, you're publishing the entire directory to NPM. Here's a screenshot of the contents of the package tar.
Please use this https://docs.npmjs.com/cli/v8/configuring-npm/package-json#files. The published size is a whopping 2.6mb.
Thanks for the great lib! I noticed some bad UAs coming up with my filters from time to time, which might caused by fake generic UAs being collected and leaking into releases. Since the core value of this lib is to provide realistic UAs it would be good to filter the bad ones out all together.
"{userAgent}"
value in v1.0.343:{appName:"Netscape",connection:{downlink:10,effectiveType:"4g",rtt:50},platform:"MacIntel",pluginsLength:3,vendor:"Google Inc.",userAgent:"{userAgent}",viewportHeight:670,viewportWidth:1190,deviceCategory:"desktop",screenHeight:900,screenWidth:1440,weight:3278510796810622e-20}`
MacIntel
, but should be Linux
:{appName:"Netscape",connection:{downlink:4.5,effectiveType:"4g",rtt:100},platform:"MacIntel",pluginsLength:3,vendor:"Google Inc.",userAgent:'"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36"',viewportHeight:800,viewportWidth:1670,deviceCategory:"desktop",screenHeight:1050,screenWidth:1680,weight:6634456214284333e-20}
deviceCategory: 'desktop'
and platform: 'MacIntel'
:{appName:"Netscape",connection:{downlink:8,effectiveType:"4g",rtt:150},platform:"MacIntel",pluginsLength:0,vendor:"Google Inc.",userAgent:"Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1",viewportHeight:810,viewportWidth:1410,deviceCategory:"desktop",screenHeight:1050,screenWidth:1680,weight:8770374263814142e-20}
My chrome (windows desktop) sends these headers related to user-agent / device identification:
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36
Obviously this pkg provides User-Agent
, but does it give things like sec-ch-ua*? It'd be pretty cool if it did, closer to a real world browser that way.
I've implemented a ruby library that uses the user-agents.json.gz and found that sometimes there is an extra quote(s) in userAgent, like this:
"userAgent": "\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
or this:
"userAgent": "\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36\"",
The nightly build to update the user-agent json has been failing for about two months.
https://app.circleci.com/pipelines/github/intoli/user-agents?branch=master
In this repo dot-json
is not a dependency.
But on npmjs it is listed as such:
If you install user-agents with npm install user-agents
you will see inside its package.json that dot-json is present.
I would guess that whoever is running npm publish (probably it is run from circle-ci, as far as I can tell) has dot-json as a dependency. This means it is pushed to all users and downloaded when the package is used. (This isn't in itself so bad, but dot-json depends on a lib that pollutes the underscore
package, which is potentially more problematic.)
The fix is installing dot-json with npm install dot-json --no-save
in your circle-ci script.
(This might be because the default behavior of npm changed with npm@5 to imply --save.)
Hello @intoli,
Thanks for the very useful tool. I was wondering if you'd accept to have your library replicated in python (I can do it if you want), as I would very much like to have your user-agents available in a python environment.
Have a great day,
In API documentation: class: UserAgent([filters])
filters <Array, Function, Number, Object, RegExp, or String> - A set of filters to apply to the generated user agents.
What is Number
?
" Unlike other random user agent generation libraries, the User-Agents package is updated automatically on a daily basis."
On NPM, however it does not seem to have been updated for a while.
Could you update de data ?
Thanks :)
I have identified a security vulnerability in one of the dependencies used by user-agents
v1.0.1444. The dependency underscore-keypath
is vulnerable to Prototype Pollution, as described in CVE-2023-26139.
user-agents
v1.0.1444user-agents
package using npm with the version v1.0.1444.npm audit
in the project directory.Thank you for your attention to this matter.
Hi,
Great module. Thank you for it.
However, I'm facing issues while using it in a TypeScript project. I have tried the following approaches:
As per README
(import UserAgent from 'user-agents';
)
I get TypeError: user_agents_1.default is not a constructor
error
Based on #10
(import * as UserAgent from 'user-agents';
)
I get TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
error
I investigated and I tried to learn more about the issue, you should check this StackOverflow.
Is it possible to fix it in the near-term so as to avoid using esModuleInterop
flag?
When creating random 2000 agents with deviceCategory mobile one of them is returned for tablet.
Mozilla/5.0 (Linux; Android 9; Chrome tablet) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.0 Safari/537.36
There's only 2 entries for Firefox based user agents, this is a very small pool of relevant user agents, I can contribute lots of new Firefox user agents, if that's the right way to do it. (Manually)
vite+vue3
universalModuleDefinition:10
Uncaught ReferenceError: global is not defined
at node_modules/user-agents/dist/index.js (universalModuleDefinition:10:4)
at __require2 (chunk-HYZYPRER.js?v=756193e6:15:50)
at startup:4:28
when i used user-agents in browser extension environment (manifest v3,execute in background worker):
const userAgent = new UserAgent({deviceCategory: ‘desktop’}).data
i got a error like this :
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*".
It looks related to browser content_security_policy ,and chrome does not support to set ‘unsafe-eval’ in extension manifest.json file。
as mentioned above,this library cannot be used in the browser extension environment
const filter = {
deviceCategory: 'mobile',
platform: 'Android'
};
this filter is returning error
Error: No user agents matched your filters.
why i can't specify android phones?
Hi,
I do this userAgent = new UserAgents({ deviceCategory: 'desktop', userAgent: /^Mozilla/ });
to get Mozilla user agent on desktop device.
I want to get the first 500 most-common/recent Mozilla user agent on desktop device.
To do that I probably need to do the filtering using the custom function.
I don't know how to filter to get the first 500 most-common/recent Mozilla user agent on desktop device.
Can you help me?
Might be good to add this to the documentation :
user-agents.json.gz
contains browser fingerprints not user-agents strings so it will give you a representation of what is most used at the time period depending of the version of the lib.For example :
Top user agent for v1.0.378
3014 "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
1096 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
417 "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
410 "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
384 "userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
322 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
289 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
273 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15",
195 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
194 "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
144 "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1",
106 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
96 "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1",
95 "userAgent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
95 "userAgent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
94 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
86 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15",
86 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
84 "userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
78 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
Top user-agent for the last version (master)
1668 "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
1378 "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36",
465 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
403 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
383 "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
260 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36",
237 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36",
197 "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36",
151 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15",
142 "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Mobile/15E148 Safari/604.1",
126 "userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
113 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
110 "userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36",
106 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
96 "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
80 "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36",
66 "userAgent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
64 "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/79.0.3945.79 Chrome/79.0.3945.79 Safari/537.36",
64 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
62 "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36",
You can reproduce with this command
zcat user-agents.json.gz | grep userAgent | sort | uniq -c | sort -nr | head -20
can you make a list of the most popular browser user agent of 2019 (top 50 or 100?), and yearly update that? for another repo sqlmap
(google translated ^^''
I don't know is this information present in data sources, but it would be very useful to add, if possible
I'm trying to get this implemented with puppeteer, what am I doing wrong?
const UserAgent = require('user-agents');
// set UserAgent
const userAgent = new UserAgent();
await page.setUserAgent(userAgent);
getting this error
(node:19627) UnhandledPromiseRejectionWarning: Error: Protocol error (Network.setUserAgentOverride): Invalid parameters userAgent: string value expected
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.