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

parse-search-engine

v0.0.1

Published

Parse search engine HTML results into structured JSON or Markdown

Downloads

119

Readme

parse-search-engine

Tests codecov npm version npm downloads Node.js License: MIT

Parse search engine HTML results into structured JSON or Markdown. Auto-detects Google, Bing, and DuckDuckGo.


Install

npm install parse-search-engine

Quick start

import { SearchEngineParser } from "parse-search-engine";

const scraper = new SearchEngineParser();

// Auto-detect engine, returns JSON (default)
const json = scraper.parse(html);

// Returns Markdown (great for LLMs)
const markdown = scraper.parse(html, { outputFormat: "markdown" });

API

scraper.parse(html, options?)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | html | string | — | Raw HTML from a search results page | | options.engine | "google" \| "bing" \| "duckduckgo" | auto-detect | Force a specific parser | | options.outputFormat | "json" \| "markdown" | "json" | Output format |

Returns: string — JSON string or Markdown string.

Throws: Error if the search engine cannot be auto-detected and no engine option is provided.


Output formats

JSON

{
  "search_engine": "google",
  "query": "python web scraping",
  "total_results": 3,
  "results": [
    {
      "title": "Web Scraping with Python - Real Python",
      "url": "https://realpython.com/python-web-scraping/",
      "description": "Learn how to scrape websites with Python...",
      "position": 1,
      "result_type": "organic",
      "metadata": {}
    }
  ],
  "detection_confidence": 0.9,
  "parsed_at": "2026-03-14T12:00:00.000Z",
  "metadata": {}
}

Markdown

# Search Results: python web scraping

**Search Engine:** Google
**Total Results:** 3
**Parsed:** 2026-03-14T12:00:00.000Z

---

## Organic Results

### 1. Web Scraping with Python - Real Python
Learn how to scrape websites with Python...

**URL:** https://realpython.com/python-web-scraping/

Supported result types

| result_type | Description | |---------------|-------------| | organic | Standard organic search result | | featured_snippet | Google featured snippet (position 0) | | knowledge_panel | Knowledge panel entry | | news | News result | | image | Image result | | ai_overview | Google AI Overview | | people_also_ask | People Also Ask question | | people_saying | Social post ("What people are saying") | | people_also_search | "People also search for" carousel item | | related_products | Related products/services suggestion | | sponsored | Paid/sponsored result |


Advanced usage

Access parsed data directly

import { detect, getParserForEngine } from "parse-search-engine";

// Detect engine and get confidence score
const detection = detect(html);
if (detection) {
  console.log(detection.engine);     // "google"
  console.log(detection.confidence); // 0.9
}

// Use a parser directly for SearchResults object
const parser = getParserForEngine("google");
const results = parser.parse(html);
console.log(results.results.length);

Add a custom parser

Implement the BaseParser interface:

import type { BaseParser } from "parse-search-engine";
import type { CheerioAPI } from "cheerio";
import type { SearchResults } from "parse-search-engine";
import * as cheerio from "cheerio";

class YandexParser implements BaseParser {
  readonly engineName = "yandex" as const;

  canParse($: CheerioAPI): number {
    const title = $("title").text();
    return title.includes("Yandex") ? 0.9 : 0;
  }

  extractQuery($: CheerioAPI): string | null {
    return $('input[name="text"]').attr("value") ?? null;
  }

  parse(html: string): SearchResults {
    const $ = cheerio.load(html);
    // ... extract results
  }
}

Development

npm test              # run tests
npm run test:coverage # run tests with coverage report
npm run build         # compile TypeScript

License

MIT