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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hongfangze-browser

v1.0.0

Published

comm.browser

Readme

浏览器自动化及数据抓取

介绍

浏览器Api

开始使用

npm install hongfangze-brower

import Browser from "hongfangze-brower";

// 注意:sleep只是为了调试

// 初始化一个浏览器对象
const browser = new Browser({
    executable: {
        // 浏览器所在位置,如果已经安装Chrome浏览器,可以部传浏览器启动路径
        path: "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
    }
});
try {
    // 启动浏览器,也可以不启动,打开新标签页的时候,会自动启动
    await browser.launch();
    // 打开一个网页
    let page = await browser.newPage("http://www.baidu.com");
    // 获取网页加载的网络请求信息
    console.log("request0:", page.networks[0].request);
    console.log("response0:", page.networks[0].response);
    // 搜索框填入待搜索的内容
    await page.fill("#kw", "今天是几号");
    // 点击搜索按钮
    await page.click("#su");
    await sleep(1000);
    // 滚动元素
    await page.scroll("#searchTag", 0, 200);
    await sleep(1000);
    // 滚动整个网页到最底下
    await page.scrollToBottom();
    await sleep(1000);
    // 滚动整个网页到最上面
    await page.scrollToTop();
    await sleep(1000);
    // 获取当前网页源码,可以配合hongfangze-convert的html2dom函数进行解析html
    const html = await page.html();
    await sleep(1000);
    // 截图
    await page.screenshot("baidu.clip.jpeg");
    await page.screenshot("baidu.full.jpeg", true);
    await sleep(1000);
    // 获取网站cookie,sessionstorage等同理,亦可设置sessionstorage等数据
    const cookie = await page.javascriptRuntime(() => {
        return document.cookie;
    });
    // 在网页中执行任意javascript代码
    await page.javascriptRuntime(`
        alert(document.location.origin);
    `);
    // 在网页中执行任意javascript代码(外部变量穿透进网页)
    var age = 30, name = "hongfangze";
    await page.javascriptRuntime<[string, number]>((name, age) => {
        alert(`${document.location.origin}:我叫${name},我已经${age}岁了!`);
    }, null, name, age);
    // 关闭标签页,也可以不关闭,最后一起释放整个浏览器
    await page.close();
    await sleep(1000);
} catch (e) {
    console.error(e);
} finally {
    // 关闭并释放浏览器进程
    await sleep(3000);
    await browser.release();
}

版本迭代记录

2025-06-05 v1.0.0

  • 浏览器的启动,加载网页实现。
  • 打开的页面支持一些操作,获取源码、在远程页面中执行javascript等。