Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
random-headers
Advanced tools
Generates random HTTP headers and user-agents that mimic a real browser.
random-headers
is a lightweight Node.js package that generates random HTTP request headers and User-Agent strings. This package is useful for web scraping, testing, or any use case where you need to simulate different browser headers dynamically.
You can install the package via npm:
npm install random-headers
Here’s an example of how you can use the randomHeaders and randomUserAgent functions in your Node.js application:
const { randomHeaders, randomUserAgent } = require('random-headers');
// Generate a set of random headers
const headers = randomHeaders();
console.log(headers);
// Generate a random User-Agent string
const userAgent = randomUserAgent();
console.log(userAgent);
// Headers
{
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'en-US,en;q=0.8',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/58.0.3029.110 Chrome/58.0.3029.110 Safari/537.36'
}
// User-Agent
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
You can also generate random headers or user agents directly from the command line:
npx random-headers
npx random-user-agent
randomHeaders(): { [key: string]: string }
Generates a random set of HTTP headers based on real-world browser data.
Returns:
randomUserAgent(): string
Generates a random User-Agent string from different browsers and platforms.
This package includes TypeScript type declarations. You can use it seamlessly in TypeScript projects.
Example:
import { randomHeaders, randomUserAgent } from 'random-headers';
const headers = randomHeaders();
const userAgent = randomUserAgent();
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to open issues or submit pull requests if you want to contribute to the project.
FAQs
Generates random HTTP headers and user-agents that mimic a real browser.
The npm package random-headers receives a total of 12 weekly downloads. As such, random-headers popularity was classified as not popular.
We found that random-headers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.