npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

random-http-ua

v1.0.2

Published

批量生成http请求头的user-agent

Downloads

222

Readme

random-http-ua

随机生成一个http请求的user-agent

Feature

  • 支持pc端:winodws、 macos
  • 支持移动端:android、 ios
  • android端支持机型:huawei、 mi、 vivo、 oppo、 samsung
  • 支持各种应用:qq浏览器、 uc浏览器、 ie、 chrome、 safari、 微信
  • 可指定随机概率
  • 自定义ua类型(详细见下文Params)

Install

npm i random-http-ua

Useage

/**
 * 随机生成浏览器的ua
 * @param {String | Number} ua的数量
 * @param {Object} 自定义ua的类型(可设置概率,详见例子)
 * @return {String | Array} ua
 */
generateUa(num = 1, opts = {})

eg.

// 生成100个ua:移动端占70%,其中ios占90%;pc占比30%(100%-70%),其中全部为macos
let randomUa = require('random-http-ua')
randomUa.generateUa(100, {
    device: ['pc', '70^mobile'],
    pcOs: ['macos'],
    mobileOs: ['android', '90^ios'],
})

Params

// 可自定义的ua类型
opts: {
    'device':       Array  eg.['mobile', 'pc']                                  // 设备类型
    'pcOs':         Array  eg.['windows', 'macos']                              // pc端操作系统
    'mobileOs':     Array  eg.['android', 'ios']                                // 移动端操作系统
    'windowsApp':   Array  eg.['ie', 'edge', 'qb', 'chrome', 'firfox', '360']   // win系统下的浏览器应用
    'macosApp':     Array  eg.['safari', 'chrome', 'firfox']                    // macos系统下的浏览器应用
    'iosApp':       Array  eg.['safari', 'qb', 'wechat']                        // ios浏览器应用
    'androidBrand': Array  eg.['huawei', 'mi', 'vivo', 'oppo', 'samsung']       // 安卓机型
    'androidApp':   Array  eg.['wechat', 'uc', 'baidu', 'qb', 'native']         // 浏览器应用
}

Todo

  • [X] 增加更多的自定义设置
  • [ ] 增加英文文档
  • [ ] 增加更多的安卓机型、浏览器应用