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

scrapy-spider-gen

v0.2.18

Published

Pi extension — génère des spiders Scrapy depuis des pages HTML

Downloads

188

Readme

scrapy-spider-gen

A Pi extension that generates Scrapy spiders from web pages. Downloads HTML, strips the noise, and feeds the cleaned DOM to the LLM for automatic selector extraction and spider generation.

The problem

A typical e-commerce page weighs 500KB–2MB of raw HTML. Most of it is noise for an LLM trying to identify CSS/XPath selectors on product content:

  • <style> / <link> blocks
  • <script> tags (analytics, tracking, hydration)
  • Dozens of data-* attributes
  • Inline SVG icons
  • HTML comments

How it works

Raw HTML (2MB)
      │
      ▼
[scrapy-spider-gen extension]
  ├── Strip <script>, <style>, <svg>, <noscript>, <iframe>, …
  ├── Filter parasitic attributes (style, onclick, data-tracking…)
  ├── Keep only structural DOM
  └── Optionally extract product zone only (main, article…)
      │
      ▼
Cleaned HTML (20–50KB)
      │
      ▼
[LLM via Pi]  ←  spider template + item fields
      │
      ▼
Completed Scrapy spider

Install

pi install npm:scrapy-spider-gen

Or from source:

git clone <this-repo>
cd pi-vapalape
npm install
pi install ./

Looking for omp.sh (oh-my-pi) support? See scrapy-spider-gen-omp — a sibling package that targets the @oh-my-pi/pi-coding-agent runtime.

Usage

Command: /spider-create

/spider-create url=<url_or_path> [template=<path>] [level=light|normal|aggressive] [prompt=<text_or_path>]

| Parameter | Description | Default | |-----------|-------------|---------| | url | HTTPS URL or local file path to the HTML page | required | | template | Path to a Scrapy spider template file | — | | level | Cleaning intensity | normal | | prompt | Custom prompt (replaces the default). Inline text or path to a prompt file | — |

Examples:

/spider-create url=https://shop.example.com/product/42
/spider-create url=https://shop.example.com/product/42 template=./spider.py level=aggressive
/spider-create url=./pages/product.html level=light
/spider-create url=https://shop.example.com/product/42 prompt=./my_instructions.txt

Command: /spider-help

Shows extension usage, available commands, clean levels, and custom prompt variables.

Custom prompt variables

When using prompt=<file>, the following variables are resolved in the prompt content:

| Variable | Value | |----------|-------| | {source} | URL or file path of the HTML page | | {level} | Cleaning level | | {templateClause} | , template="<path>" or empty string |

Tool: spider_clean

LLM-callable tool that fetches, cleans, and returns structural HTML for Scrapy selector analysis. The LLM can also call it directly when generating or completing a spider.

Clean levels

| Level | What it does | |-------|-------------| | light | Removes <script>, <style>, <svg>, <noscript>, <iframe>, <canvas>, <video>, <audio>, <link>, <meta>, <template> | | normal | light + filters parasitic attributes (style, onclick, data-tracking…), keeps only structural attributes (id, class, href, src, alt, data-product-*, Schema.org…) | | aggressive | normal + extracts only the product zone using heuristics (Schema.org markers, .product-detail, main, article, [role='main']…) |

Safety

Cleaned HTML is capped at 400KB to stay within LLM context limits. If the output exceeds this threshold, it is truncated with a warning.

Architecture

src/
├── index.ts          — Entry point: /spider-create command + spider_clean tool
├── arg-parser.ts     — Parses /spider-create command arguments
├── fetcher.ts        — Downloads HTML from URL or reads local file
├── html-cleaner.ts   — Cleans HTML: removes noise, filters attributes, extracts product zone
└── *.test.ts         — Co-located tests (vitest)

Development

npm install
npm test            # vitest run
npm run check       # biome lint + format
npm run format      # auto-fix formatting
npm run build       # tsc
npm run ci          # check + build + test

License

MIT