Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dropoutlab-dev/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.
https://github.com/dropoutlab-dev/user-agents-generator
automation javascript puppeteer user-agent
Last synced: 3 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/dropoutlab-dev/user-agents-generator
- Owner: dropoutlab-dev
- License: mit
- Created: 2023-02-21T08:19:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-21T08:52:49.000Z (almost 2 years ago)
- Last Synced: 2024-04-29T16:45:12.216Z (8 months ago)
- Topics: automation, javascript, puppeteer, user-agent
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 8
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
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.
## Usage
1. Install the module in your project:
```bash
npm install user-agent-generator
```2. Import the module in your script:
```javascript
const userAgentGenerator = require('user-agent-generator');
```3. Use the module's methods to generate user agents for different browsers and devices:
```javascript
`const chromeUserAgent = userAgentGenerator.chrome();
const firefoxUserAgent = userAgentGenerator.firefox();
const safariUserAgent = userAgentGenerator.safari();
const androidUserAgent = userAgentGenerator.android();
const iosUserAgent = userAgentGenerator.ios();`
```
4. Pass the generated user agent string to your Puppeteer automation scripts:```javascript
const puppeteer = require('puppeteer');
const chromeUserAgent = userAgentGenerator.chrome();
(async () => {
const browser = await puppeteer.launch({
headless: true,
args: [`--user-agent=${chromeUserAgent}`]
});
const page = await browser.newPage();
await page.goto('https://www.example.com');
// your automation code here
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.