JSPM

user-agents-generator

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q50731F
  • License MIT

A Minimal Package to Generate unlimited user agents

Package Exports

  • user-agents-generator
  • user-agents-generator/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (user-agents-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

User Agents Generator

This is a Node.js module that provides a simple way to generate user agent strings for various web browsers and mobile devices. The generated user agents can be used in web scraping or automation scripts to mimic the behavior of real users.Change user agents dynamically easily using this package.

Usage

  1. Install the module in your project:
npm install user-agents-generator
  1. Import the module in your script:
const userAgentGenerator = require('user-agents-generator');
  1. Use the module's methods to generate user agents for different browsers and devices:
const chromeUserAgent = userAgentGenerator.chrome();
const firefoxUserAgent = userAgentGenerator.firefox();
const safariUserAgent = userAgentGenerator.safari();
const androidUserAgent = userAgentGenerator.android();
const iosUserAgent = userAgentGenerator.ios();
  1. Pass the generated user agent string to your Puppeteer automation scripts:
const puppeteer = require('puppeteer');
const chromeUserAgent = userAgentGenerator.chrome();
(async () => {
  const browser = await puppeteer.launch({
    headless: true,
    //You can setup more additional args later on.
    args: [`--user-agent=${chromeUserAgent}`]
  });
  const page = await browser.newPage();

  // Write your code here instead of Navigating into `example.com` 🚀
    console.log('🚀 Navigate into example.com');
    await page.goto('https://example.com', { waitUntil: 'domcontentloaded'});

  // your automation code here

    console.log('☑️ Broser Closed');
  await browser.close();
})();

API

userAgentGenerator.chrome()

Generates a user agent string for the Google Chrome browser.

userAgentGenerator.firefox()

Generates a user agent string for the Mozilla Firefox browser.

userAgentGenerator.safari()

Generates a user agent string for the Apple Safari browser.

userAgentGenerator.android()

Generates a user agent string for an Android device.

userAgentGenerator.ios()

Generates a user agent string for an iOS device.

License

This module is released under the MIT License.