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

xx-ray

v2.0.2

Published

crawler

Downloads

5

Readme

這是基於 x-ray 改來的 crawler

使用範例

看 example.js

新增功能

- setConfig(obj) 可設定各種參數

	xray.setConfig({
		limit: 2,
		paginate: 'ul li'
	})

- limit 可給 Infinity 就會所有頁面全抓,給 2 就只抓兩頁

- .paginate() 功能已修正,原本同一頁會抓兩次,然後第三頁就爛掉

- 每抓完一頁會詢問是否要繼續
	- pageEventHandler() 內 return false 即可 cancel

- 抓取中能看到 progress or event 嗎?
	- 因為我想判斷每條新聞的日期再決定是否要抓下頁

	← 沒辦法,因為是以整頁為單位先抓下來,然後走訪頁面上的10筆資料
	- 只能在 pageEventHandler 內判斷這批抓回來的10筆資料是否已重覆了,然後 return false 取消掉後續抓取
		- 並且將重覆的幾條 item 給刪掉

我改掉的部份

- 將所有 chaining method 全拿掉,參數改用 config 傳入

- write() 也會觸發 node() 再跑一次,能一律改成 promise 版嗎?
	- 這些列在 methods[] 中的指令已全拿掉

為何要用這個 lib 為基礎來改?

- 可明確標示出 target graph 的結構,很清楚要抓哪些欄位,與它們相應的 query string
- 可用 [{}] 來表示是要抓 Array of items
- 因為他是 cheerio 作者,原本以為應該會很優

下一步

- 目前此份 code 堪用,將來大規模 scale 時再找時間回來重寫