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

matman-crawler

v6.0.20

Published

Easy to write build preload script in nightmare

Downloads

20

Readme

matman-crawler

matman 端对端测试方案中使用到的前端爬虫处理工具,更多资料请参考: matman 官方文档

1. 安装

$ npm install matman-crawler --save

2. 功能介绍

2.1 将多个文件打包成一个单文件

nightmare 提供了 custom preload script 的能力,支持注入一个单文件脚本(我们称之为前端爬虫脚本)。

但是它有两个限制:

  • 只支持加载一个文件
  • 只支持加载本地文件,不能加载网络请求回来的文件

而实际情况时,我们更倾向于使用 CommonJS 规范来组织项目,自然会存在多个组件和多个文件的情况。因此,基于 webpack 4,我们开发了这个工具来将源代码打包成一个独立的文件。

2.2 可配置注入 jQuery

为了更好地爬取 DOM 上的信息,我们构建前端爬虫脚本时,如果传递 crawlerInjectJQuery 值为 true ,则将注入 jQuery 3.3.1 slim 版本。这样在写前端爬虫脚本时,可以直接用 jQuery 了。

2.3 若使用了 nightmare 则已自动注入了其需要的前置脚本

按照 custom preload script 的要求,注入脚本中必须加上一段特殊的代码,以便于与 electron 通信。我们已经在打包时进行了自动处理,已注入了 nightmare-preload.js

3. API 说明

3.1 build(matmanConfig)

利用 webpack 按照规则进行构建。构建完成之后会生成构建文件。