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

@ahmedrangel/rand-user-agent

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ahmedrangel/rand-user-agent

This is an adapted version of rand-user-agent specifically designed for environments lacking access to server file systems, such as Cloudflare Workers.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
decreased by-57.35%
Maintainers
1
Weekly downloads
 
Created
Source

Random User Agent

This is an adapted version of rand-user-agent specifically designed for environments lacking access to server file systems, such as Cloudflare Workers.

  • Obtain the dataset of User-Agents by downloading the raw JSON file from the rand-user-agent data by WebScrapingAPI.
  • Enhance access efficiency by storing this data in a Bucket service of your convenience (Amazon S3, Cloudflare R2, ...).

Installation

Run the following command in the main folder of your project:

# Using npm
npm i @ahmedrangel/rand-user-agent


# Using pnpm
pnpm add @ahmedrangel/rand-user-agent


# Using yarn
yarn add @ahmedrangel/rand-user-agent

Usage Example

import { randUA } from "@ahmedrangel/rand-user-agent";

// ...

// Fetching the raw JSON URL file from rand-user-agent repository
// const response = await fetch("https://raw.githubusercontent.com/WebScrapingAPI/rand-user-agent/master/data/user-agents.json");

// Using Coudflare R2
const response = await env.YOUR_BUCKET.get("user-agents.json");
const jsonData = await response.json();
const agent = randUA(jsonData, "desktop");

console.log(agent);

You can also provide a browser and an operating system in the parameters of randUA in order to filter out the user agents:

import { randUA } from "@ahmedrangel/rand-user-agent";

// ...

const agent = randUA(jsonData, "desktop", "chrome", "linux");

console.log(agent);

Keywords

FAQs

Package last updated on 08 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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