New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ahmedrangel/rand-user-agent

Package Overview
Dependencies
Maintainers
1
Versions
25
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
Version published
Weekly downloads
135
3275%
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

user-agent

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